Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the crash bug when attempting to swap fluids
- Loading branch information
Showing
3 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
src/main/java/tconstruct/util/network/packet/PacketUpdateTE.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
package tconstruct.util.network.packet; | ||
|
||
import io.netty.buffer.ByteBuf; | ||
import io.netty.channel.ChannelHandlerContext; | ||
import java.io.IOException; | ||
import net.minecraft.entity.player.EntityPlayer; | ||
import net.minecraft.nbt.NBTTagCompound; | ||
import net.minecraft.network.PacketBuffer; | ||
import net.minecraft.tileentity.TileEntity; | ||
|
||
public class PacketUpdateTE extends AbstractPacket { | ||
private int x, y, z; | ||
private NBTTagCompound data; | ||
|
||
public PacketUpdateTE() { | ||
|
||
} | ||
|
||
public PacketUpdateTE(int x, int y, int z, NBTTagCompound data) { | ||
this.x = x; | ||
this.y = y; | ||
this.z = z; | ||
this.data = data; | ||
} | ||
|
||
@Override | ||
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { | ||
System.out.println("Encoding..."); | ||
PacketBuffer pbuff = new PacketBuffer(buffer); | ||
pbuff.writeInt(x); | ||
pbuff.writeShort(y); | ||
pbuff.writeInt(z); | ||
try { | ||
pbuff.writeNBTTagCompoundToBuffer(data); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer) { | ||
System.out.println("Decoding..."); | ||
PacketBuffer pbuff = new PacketBuffer(buffer); | ||
x = pbuff.readInt(); | ||
y = pbuff.readShort(); | ||
z = pbuff.readInt(); | ||
try { | ||
data = pbuff.readNBTTagCompoundFromBuffer(); | ||
} catch (IOException e) { | ||
e.printStackTrace(); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleClientSide(EntityPlayer player) { | ||
System.out.println("Handling client..."); | ||
TileEntity te = player.worldObj.getTileEntity(x, y, z); | ||
|
||
if (te != null) { | ||
te.readFromNBT(data); | ||
} | ||
} | ||
|
||
@Override | ||
public void handleServerSide(EntityPlayer player) { | ||
System.out.println("Handling server..."); | ||
} | ||
|
||
} |