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
|
package gregtech.api.net;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.IBlockAccess;
import com.google.common.io.ByteArrayDataInput;
import io.netty.buffer.ByteBuf;
/**
* Used to transfer Block Events in a much better fashion
*/
public class GTPacketBlockEvent extends GTPacketNew {
private int mX, mZ;
private short mY;
private byte mID, mValue;
public GTPacketBlockEvent() {
super(true);
}
public GTPacketBlockEvent(int aX, short aY, int aZ, byte aID, byte aValue) {
super(false);
mX = aX;
mY = aY;
mZ = aZ;
mID = aID;
mValue = aValue;
}
@Override
public void encode(ByteBuf aOut) {
aOut.writeInt(mX);
aOut.writeShort(mY);
aOut.writeInt(mZ);
aOut.writeByte(mID);
aOut.writeByte(mValue);
}
@Override
public GTPacketNew decode(ByteArrayDataInput aData) {
return new GTPacketBlockEvent(
aData.readInt(),
aData.readShort(),
aData.readInt(),
aData.readByte(),
aData.readByte());
}
@Override
public void process(IBlockAccess aWorld) {
if (aWorld != null) {
final TileEntity tTileEntity = aWorld.getTileEntity(mX, mY, mZ);
if (tTileEntity != null) tTileEntity.receiveClientEvent(mID, mValue);
}
}
@Override
public byte getPacketID() {
return GTPacketTypes.BLOCK_EVENT.id;
}
}
|