2013-12-05 22:42:00 +01:00
|
|
|
package mekanism.common.network;
|
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
2014-06-02 17:33:19 +02:00
|
|
|
import mekanism.common.Mekanism;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2013-12-05 22:42:00 +01:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
public class PacketKey extends MekanismPacket
|
2013-12-05 22:42:00 +01:00
|
|
|
{
|
|
|
|
public int key;
|
|
|
|
public boolean add;
|
2014-06-03 19:54:45 +02:00
|
|
|
|
|
|
|
public PacketKey() {}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
public PacketKey(int k, boolean a)
|
2013-12-05 22:42:00 +01:00
|
|
|
{
|
2014-04-20 22:15:44 +02:00
|
|
|
key = k;
|
|
|
|
add = a;
|
2013-12-05 22:42:00 +01:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-06-02 17:33:19 +02:00
|
|
|
@Override
|
|
|
|
public void write(ChannelHandlerContext ctx, ByteBuf dataStream)
|
|
|
|
{
|
|
|
|
dataStream.writeInt(key);
|
|
|
|
dataStream.writeBoolean(add);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void read(ChannelHandlerContext ctx, EntityPlayer player, ByteBuf dataStream)
|
2013-12-05 22:42:00 +01:00
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
key = dataStream.readInt();
|
|
|
|
add = dataStream.readBoolean();
|
|
|
|
|
|
|
|
if(add)
|
|
|
|
{
|
|
|
|
Mekanism.keyMap.add(player, key);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Mekanism.keyMap.remove(player, key);
|
|
|
|
}
|
2013-12-05 22:42:00 +01:00
|
|
|
}
|
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
@Override
|
|
|
|
public void handleClientSide(EntityPlayer player)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleServerSide(EntityPlayer player)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-12-05 22:42:00 +01:00
|
|
|
}
|