-
Notifications
You must be signed in to change notification settings - Fork 53
/
Entity.java
137 lines (105 loc) · 2.75 KB
/
Entity.java
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
package org.darkstorm.darkbot.minecraftbot.world.entity;
import org.darkstorm.darkbot.minecraftbot.util.IntHashMap;
import org.darkstorm.darkbot.minecraftbot.world.*;
import org.darkstorm.darkbot.minecraftbot.world.block.BlockLocation;
public abstract class Entity {
protected final World world;
protected final int id;
protected double x, y, z, yaw, pitch;
protected Entity rider, riding;
protected boolean dead;
public Entity(World world, int id) {
this.world = world;
this.id = id;
}
public World getWorld() {
return world;
}
public int getId() {
return id;
}
public double getX() {
return x;
}
public double getY() {
return y;
}
public double getZ() {
return z;
}
public double getYaw() {
return yaw;
}
public double getPitch() {
return pitch;
}
public Entity getRider() {
return rider;
}
public Entity getRiding() {
return riding;
}
public boolean isDead() {
return dead;
}
public void setX(double x) {
this.x = x;
}
public void setY(double y) {
this.y = y;
}
public void setZ(double z) {
this.z = z;
}
public void setYaw(double yaw) {
this.yaw = yaw;
}
public void setPitch(double pitch) {
this.pitch = pitch;
}
public void setRider(Entity rider) {
this.rider = rider;
}
public void setRiding(Entity riding) {
this.riding = riding;
}
public void setDead(boolean dead) {
this.dead = dead;
}
public WorldLocation getLocation() {
return new WorldLocation(x, y, z);
}
public void setLocation(WorldLocation location) {
x = location.getX();
y = location.getY();
z = location.getZ();
}
public void updateMetadata(IntHashMap<WatchableObject> metadata) {
}
public double getDistanceTo(double x, double y, double z) {
return Math.sqrt(Math.pow(this.x - x, 2)
+ Math.pow((this.y + 1) - y, 2) + Math.pow(this.z - z, 2));
}
public int getDistanceToSquared(double x, double y, double z) {
return (int) (Math.pow(this.x - x, 2) + Math.pow((this.y + 1) - y, 2) + Math
.pow(this.z - z, 2));
}
public double getDistanceTo(Entity other) {
return getDistanceTo(other.getX(), other.getY(), other.getZ());
}
public int getDistanceToSquared(Entity other) {
return getDistanceToSquared(other.getX(), other.getY(), other.getZ());
}
public double getDistanceTo(WorldLocation location) {
return getDistanceTo(location.getX(), location.getY(), location.getZ());
}
public double getDistanceToSquared(WorldLocation location) {
return getDistanceTo(location.getX(), location.getY(), location.getZ());
}
public double getDistanceTo(BlockLocation location) {
return getDistanceTo(location.getX(), location.getY(), location.getZ());
}
public double getDistanceToSquared(BlockLocation location) {
return getDistanceTo(location.getX(), location.getY(), location.getZ());
}
}