Position.java
1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.mumfrey.liteloader.util;
import net.minecraft.entity.Entity;
import net.minecraft.util.Vec3;
/**
* A 3D vector position with rotation as well
*
* @author Adam Mummery-Smith
*/
public class Position extends Vec3
{
public final float yaw;
public final float pitch;
public Position(double x, double y, double z)
{
this(x, y, z, 0.0F, 0.0F);
}
public Position(double x, double y, double z, float yaw, float pitch)
{
super(x, y, z);
this.yaw = yaw;
this.pitch = pitch;
}
public Position(Entity entity)
{
this(entity.posX, entity.posY, entity.posZ, entity.rotationYaw, entity.rotationPitch);
}
public Position(Entity entity, boolean usePrevious)
{
this(usePrevious ? entity.prevPosX : entity.posX, usePrevious ? entity.prevPosY : entity.posY, usePrevious ? entity.prevPosZ : entity.posZ, usePrevious ? entity.prevRotationYaw : entity.rotationYaw, usePrevious ? entity.prevRotationPitch : entity.rotationPitch);
}
public void applyTo(Entity entity)
{
entity.posX = this.xCoord;
entity.posY = this.yCoord;
entity.posZ = this.zCoord;
entity.rotationYaw = this.yaw;
entity.rotationPitch = this.pitch;
}
@Override
public String toString()
{
return "(" + this.xCoord + ", " + this.yCoord + ", " + this.zCoord + ", " + this.yaw + ", " + this.pitch + ")";
}
}