-
Notifications
You must be signed in to change notification settings - Fork 497
/
EntityData.java
52 lines (42 loc) · 1.46 KB
/
EntityData.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
package buildcraft.transport;
import buildcraft.api.transport.IPipedItem;
import buildcraft.core.utils.EnumColor;
import java.util.EnumSet;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
public class EntityData {
// TODO: Move passive data here too, like position, speed and all?
// TODO: Create an object pool?
public boolean toCenter = true;
public final IPipedItem item;
public EnumColor color;
public ForgeDirection input = ForgeDirection.UNKNOWN;
public ForgeDirection output = ForgeDirection.UNKNOWN;
public EnumSet<ForgeDirection> blacklist = EnumSet.noneOf(ForgeDirection.class);
public EntityData(IPipedItem item, ForgeDirection orientation) {
this.item = item;
this.input = orientation;
}
public EntityData(IPipedItem item) {
this.item = item;
}
public void reset() {
toCenter = true;
blacklist.clear();
output = ForgeDirection.UNKNOWN;
}
public void writeToNBT(NBTTagCompound data) {
data.setBoolean("toCenter", toCenter);
data.setInteger("input", input.ordinal());
data.setInteger("output", output.ordinal());
data.setByte("color", color != null ? (byte) color.ordinal() : -1);
}
public void readFromNBT(NBTTagCompound data) {
toCenter = data.getBoolean("toCenter");
input = ForgeDirection.getOrientation(data.getInteger("input"));
output = ForgeDirection.getOrientation(data.getInteger("output"));
byte c = data.getByte("color");
if (c != -1)
color = EnumColor.fromId(c);
}
}