mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-18 19:39:14 +00:00
45 lines
1.4 KiB
Java
45 lines
1.4 KiB
Java
package crazypants.enderio.conduit.gui;
|
|
|
|
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 io.netty.buffer.ByteBuf;
|
|
import net.minecraft.entity.player.EntityPlayerMP;
|
|
|
|
public class PacketSlotVisibility implements IMessage, IMessageHandler<PacketSlotVisibility, IMessage> {
|
|
|
|
private boolean inputVisible;
|
|
private boolean outputVisible;
|
|
|
|
public PacketSlotVisibility() {
|
|
}
|
|
|
|
public PacketSlotVisibility(boolean inputVisible, boolean outputVisible) {
|
|
this.inputVisible = inputVisible;
|
|
this.outputVisible = outputVisible;
|
|
}
|
|
|
|
@Override
|
|
public void fromBytes(ByteBuf bb) {
|
|
int value = bb.readUnsignedByte();
|
|
inputVisible = (value & 1) != 0;
|
|
outputVisible = (value & 2) != 0;
|
|
}
|
|
|
|
@Override
|
|
public void toBytes(ByteBuf bb) {
|
|
int value = (inputVisible ? 1 : 0) | (outputVisible ? 2 : 0);
|
|
bb.writeByte(value);
|
|
}
|
|
|
|
@Override
|
|
public IMessage onMessage(PacketSlotVisibility message, MessageContext ctx) {
|
|
EntityPlayerMP player = ctx.getServerHandler().playerEntity;
|
|
if(player.openContainer instanceof ExternalConnectionContainer) {
|
|
ExternalConnectionContainer ecc = (ExternalConnectionContainer) player.openContainer;
|
|
ecc.setInoutSlotsVisible(message.inputVisible, message.outputVisible);
|
|
}
|
|
return null;
|
|
}
|
|
}
|