mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-20 04:09:43 +00:00
50 lines
1.7 KiB
Java
50 lines
1.7 KiB
Java
package crazypants.enderio.conduit.packet;
|
|
|
|
import net.minecraftforge.common.util.ForgeDirection;
|
|
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessage;
|
|
import cpw.mods.fml.common.network.simpleimpl.IMessageHandler;
|
|
import cpw.mods.fml.common.network.simpleimpl.MessageContext;
|
|
import crazypants.enderio.conduit.redstone.IInsulatedRedstoneConduit;
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
public class PacketRedstoneConduitOutputStrength extends AbstractConduitPacket<IInsulatedRedstoneConduit>
|
|
implements IMessageHandler<PacketRedstoneConduitOutputStrength, IMessage> {
|
|
|
|
private ForgeDirection dir;
|
|
private boolean isStrong;
|
|
|
|
public PacketRedstoneConduitOutputStrength() {}
|
|
|
|
public PacketRedstoneConduitOutputStrength(IInsulatedRedstoneConduit con, ForgeDirection dir) {
|
|
super(con.getBundle().getEntity(), ConTypeEnum.REDSTONE);
|
|
this.dir = dir;
|
|
isStrong = con.isOutputStrong(dir);
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf buf) {
|
|
super.toBytes(buf);
|
|
buf.writeShort(dir.ordinal());
|
|
buf.writeBoolean(isStrong);
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf buf) {
|
|
super.fromBytes(buf);
|
|
dir = ForgeDirection.values()[buf.readShort()];
|
|
isStrong = buf.readBoolean();
|
|
}
|
|
|
|
@Override
|
|
public IMessage onMessage(PacketRedstoneConduitOutputStrength message, MessageContext ctx) {
|
|
if (isInvalidPacketForGui(message, ctx)) return null;
|
|
IInsulatedRedstoneConduit tile = message.getTileCasted(ctx);
|
|
if (tile != null) {
|
|
tile.setOutputStrength(message.dir, message.isStrong);
|
|
// message.getWorld(ctx).markBlockForUpdate(message.x, message.y, message.z);
|
|
}
|
|
return null;
|
|
}
|
|
}
|