aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/gregtech/common/net
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/gregtech/common/net')
-rw-r--r--src/main/java/gregtech/common/net/MessageSetFlaskCapacity.java21
-rw-r--r--src/main/java/gregtech/common/net/MessageUpdateFluidDisplayItem.java61
2 files changed, 70 insertions, 12 deletions
diff --git a/src/main/java/gregtech/common/net/MessageSetFlaskCapacity.java b/src/main/java/gregtech/common/net/MessageSetFlaskCapacity.java
index ee869a2bd0..c65d7f2be4 100644
--- a/src/main/java/gregtech/common/net/MessageSetFlaskCapacity.java
+++ b/src/main/java/gregtech/common/net/MessageSetFlaskCapacity.java
@@ -1,10 +1,9 @@
package gregtech.common.net;
import com.google.common.io.ByteArrayDataInput;
-import com.google.common.io.ByteArrayDataOutput;
-import com.google.common.io.ByteStreams;
-import gregtech.api.net.GT_Packet;
+import gregtech.api.net.GT_Packet_New;
import gregtech.common.items.GT_VolumetricFlask;
+import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
@@ -12,7 +11,7 @@ import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import net.minecraftforge.common.DimensionManager;
-public final class MessageSetFlaskCapacity extends GT_Packet {
+public final class MessageSetFlaskCapacity extends GT_Packet_New {
private int capacity, dimID, playerID;
public MessageSetFlaskCapacity() {
@@ -39,16 +38,14 @@ public final class MessageSetFlaskCapacity extends GT_Packet {
}
@Override
- public byte[] encode() {
- ByteArrayDataOutput tOut = ByteStreams.newDataOutput(10);
- tOut.writeInt(capacity);
- tOut.writeInt(dimID);
- tOut.writeInt(playerID);
- return tOut.toByteArray();
+ public void encode(ByteBuf aOut) {
+ aOut.writeInt(capacity);
+ aOut.writeInt(dimID);
+ aOut.writeInt(playerID);
}
@Override
- public GT_Packet decode(ByteArrayDataInput aData) {
+ public GT_Packet_New decode(ByteArrayDataInput aData) {
return new MessageSetFlaskCapacity(aData.readInt(), aData.readInt(), aData.readInt());
}
@@ -64,4 +61,4 @@ public final class MessageSetFlaskCapacity extends GT_Packet {
}
}
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/gregtech/common/net/MessageUpdateFluidDisplayItem.java b/src/main/java/gregtech/common/net/MessageUpdateFluidDisplayItem.java
new file mode 100644
index 0000000000..619f528502
--- /dev/null
+++ b/src/main/java/gregtech/common/net/MessageUpdateFluidDisplayItem.java
@@ -0,0 +1,61 @@
+package gregtech.common.net;
+
+import com.google.common.io.ByteArrayDataInput;
+import gregtech.api.interfaces.IHasFluidDisplayItem;
+import gregtech.api.interfaces.tileentity.IGregTechTileEntity;
+import gregtech.api.net.GT_Packet_New;
+import io.netty.buffer.ByteBuf;
+import net.minecraft.tileentity.TileEntity;
+import net.minecraft.world.IBlockAccess;
+import net.minecraft.world.WorldServer;
+import net.minecraftforge.common.DimensionManager;
+
+public class MessageUpdateFluidDisplayItem extends GT_Packet_New {
+ private int mBlockX, mBlockY, mBlockZ, mDim;
+
+ public MessageUpdateFluidDisplayItem() {
+ super(true);
+ }
+
+ public MessageUpdateFluidDisplayItem(int mBlockX, int mBlockY, int mBlockZ, int mDim) {
+ super(false);
+ this.mBlockX = mBlockX;
+ this.mBlockY = mBlockY;
+ this.mBlockZ = mBlockZ;
+ this.mDim = mDim;
+ }
+
+ @Override
+ public byte getPacketID() {
+ return 8;
+ }
+
+ @Override
+ public void encode(ByteBuf aOut) {
+ aOut.writeInt(mBlockX);
+ aOut.writeInt(mBlockY);
+ aOut.writeInt(mBlockZ);
+ aOut.writeInt(mDim);
+ }
+
+ @Override
+ public GT_Packet_New decode(ByteArrayDataInput aData) {
+ return new MessageUpdateFluidDisplayItem(aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt());
+ }
+
+ @Override
+ public void process(IBlockAccess aWorld) {
+ WorldServer world = DimensionManager.getWorld(mDim);
+ if (world != null) {
+ if (world.blockExists(mBlockX, mBlockY, mBlockZ)) {
+ TileEntity tileEntity = world.getTileEntity(mBlockX, mBlockY, mBlockZ);
+ if (tileEntity instanceof IGregTechTileEntity) {
+ IGregTechTileEntity gtTile = (IGregTechTileEntity) tileEntity;
+ if (gtTile.getMetaTileEntity() instanceof IHasFluidDisplayItem) {
+ ((IHasFluidDisplayItem) gtTile.getMetaTileEntity()).updateFluidDisplayItem();
+ }
+ }
+ }
+ }
+ }
+}