diff options
author | Martin Robertz <dream-master@gmx.net> | 2021-05-21 08:14:43 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-21 08:14:43 +0200 |
commit | 4a80cad9a09dde4b8ba6a2d1eb32c74aaac06595 (patch) | |
tree | bd2622e852dc59118d4a6d6f3d8fa2553cde4055 /src/main/java/gregtech/api/net/GT_Packet_TileEntity.java | |
parent | 7c0098bcf8b1c83f9b06f01d6e460c7bd2ce000d (diff) | |
parent | ce0818a785bfbe928ca08e451e0b2d486cd32cdf (diff) | |
download | GT5-Unofficial-4a80cad9a09dde4b8ba6a2d1eb32c74aaac06595.tar.gz GT5-Unofficial-4a80cad9a09dde4b8ba6a2d1eb32c74aaac06595.tar.bz2 GT5-Unofficial-4a80cad9a09dde4b8ba6a2d1eb32c74aaac06595.zip |
Merge pull request #540 from GTNewHorizons/net-optimize
Get rid of intermediate byte array while sending packet
Diffstat (limited to 'src/main/java/gregtech/api/net/GT_Packet_TileEntity.java')
-rw-r--r-- | src/main/java/gregtech/api/net/GT_Packet_TileEntity.java | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java b/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java index 6d71cbd818..051be672ab 100644 --- a/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java +++ b/src/main/java/gregtech/api/net/GT_Packet_TileEntity.java @@ -1,14 +1,13 @@ package gregtech.api.net; import com.google.common.io.ByteArrayDataInput; -import com.google.common.io.ByteArrayDataOutput; -import com.google.common.io.ByteStreams; import gregtech.api.metatileentity.BaseMetaPipeEntity; import gregtech.api.metatileentity.BaseMetaTileEntity; +import io.netty.buffer.ByteBuf; import net.minecraft.tileentity.TileEntity; import net.minecraft.world.IBlockAccess; -public class GT_Packet_TileEntity extends GT_Packet { +public class GT_Packet_TileEntity extends GT_Packet_New { private int mX, mZ, mC0, mC1, mC2, mC3, mC4, mC5; private short mY, mID; private byte mTexture, mTexturePage, mUpdate, mRedstone, mColor; @@ -58,32 +57,28 @@ public class GT_Packet_TileEntity extends GT_Packet { } @Override - public byte[] encode() { - ByteArrayDataOutput tOut = ByteStreams.newDataOutput(41); + public void encode(ByteBuf aOut) { + aOut.writeInt(mX); + aOut.writeShort(mY); + aOut.writeInt(mZ); + aOut.writeShort(mID); - tOut.writeInt(mX); - tOut.writeShort(mY); - tOut.writeInt(mZ); - tOut.writeShort(mID); + aOut.writeInt(mC0); + aOut.writeInt(mC1); + aOut.writeInt(mC2); + aOut.writeInt(mC3); + aOut.writeInt(mC4); + aOut.writeInt(mC5); - tOut.writeInt(mC0); - tOut.writeInt(mC1); - tOut.writeInt(mC2); - tOut.writeInt(mC3); - tOut.writeInt(mC4); - tOut.writeInt(mC5); - - tOut.writeByte(mTexture); - tOut.writeByte(mTexturePage); - tOut.writeByte(mUpdate); - tOut.writeByte(mRedstone); - tOut.writeByte(mColor); - - return tOut.toByteArray(); + aOut.writeByte(mTexture); + aOut.writeByte(mTexturePage); + aOut.writeByte(mUpdate); + aOut.writeByte(mRedstone); + aOut.writeByte(mColor); } @Override - public GT_Packet decode(ByteArrayDataInput aData) { + public GT_Packet_New decode(ByteArrayDataInput aData) { return new GT_Packet_TileEntity(aData.readInt(), aData.readShort(), aData.readInt(), aData.readShort(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readInt(), aData.readByte(), aData.readByte(), aData.readByte(), aData.readByte(), aData.readByte()); } |