-
Notifications
You must be signed in to change notification settings - Fork 497
/
BlueprintReadConfiguration.java
executable file
·48 lines (42 loc) · 1.39 KB
/
BlueprintReadConfiguration.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
/**
* Copyright (c) 2011-2015, SpaceToad and the BuildCraft Team
* http://www.mod-buildcraft.com
*
* BuildCraft is distributed under the terms of the Minecraft Mod Public
* License 1.0, or MMPL. Please check the contents of the license located in
* http://www.mod-buildcraft.com/MMPL-1.0.txt
*/
package buildcraft.core.blueprints;
import io.netty.buffer.ByteBuf;
import net.minecraft.nbt.NBTTagCompound;
import buildcraft.api.core.ISerializable;
public class BlueprintReadConfiguration implements ISerializable {
public boolean rotate = true;
public boolean excavate = true;
public boolean allowCreative = false;
public void writeToNBT(NBTTagCompound nbttagcompound) {
nbttagcompound.setBoolean("rotate", rotate);
nbttagcompound.setBoolean("excavate", excavate);
nbttagcompound.setBoolean("allowCreative", allowCreative);
}
public void readFromNBT(NBTTagCompound nbttagcompound) {
rotate = nbttagcompound.getBoolean("rotate");
excavate = nbttagcompound.getBoolean("excavate");
allowCreative = nbttagcompound.getBoolean("allowCreative");
}
@Override
public void readData(ByteBuf stream) {
int flags = stream.readUnsignedByte();
rotate = (flags & 1) != 0;
excavate = (flags & 2) != 0;
allowCreative = (flags & 4) != 0;
}
@Override
public void writeData(ByteBuf stream) {
stream.writeByte(
(rotate ? 1 : 0) |
(excavate ? 2 : 0) |
(allowCreative ? 4 : 0)
);
}
}