mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-21 12:42:36 +00:00
More packety fun.
This commit is contained in:
1 parent
bd83138a7a
commit
d661be1f70
22 files changed
+379
-481
No files matched your search
@@ -0,0 +1,65 @@
|
||||
package crazypants.enderio.machine.alloy;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import crazypants.enderio.network.IPacketEio;
|
||||
|
||||
public class PacketClientState implements IPacketEio {
|
||||
|
||||
private int x;
|
||||
private int y;
|
||||
private int z;
|
||||
|
||||
private TileAlloySmelter.Mode mode;
|
||||
|
||||
public PacketClientState() {
|
||||
|
||||
}
|
||||
|
||||
public PacketClientState(TileAlloySmelter tile) {
|
||||
x = tile.xCoord;
|
||||
y = tile.yCoord;
|
||||
z = tile.zCoord;
|
||||
mode = tile.getMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void encode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
buf.writeInt(x);
|
||||
buf.writeInt(y);
|
||||
buf.writeInt(z);
|
||||
buf.writeShort(mode.ordinal());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void decode(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
x = buf.readInt();
|
||||
y = buf.readInt();
|
||||
z = buf.readInt();
|
||||
short ordinal = buf.readShort();
|
||||
mode = TileAlloySmelter.Mode.values()[ordinal];
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleClientSide(EntityPlayer player) {
|
||||
handle(player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleServerSide(EntityPlayer player) {
|
||||
handle(player);
|
||||
}
|
||||
|
||||
private void handle(EntityPlayer player) {
|
||||
TileEntity te = player.worldObj.getTileEntity(x, y, z);
|
||||
if(te instanceof TileAlloySmelter) {
|
||||
TileAlloySmelter me = (TileAlloySmelter) te;
|
||||
me.setMode(mode);
|
||||
player.worldObj.markBlockForUpdate(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user