2013-10-13 18:31:26 +02:00
|
|
|
package mekanism.common.network;
|
|
|
|
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
|
|
|
|
import mekanism.common.item.ItemWalkieTalkie;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import com.google.common.io.ByteArrayDataInput;
|
2014-04-20 22:15:44 +02:00
|
|
|
import io.netty.buffer.ByteBuf;
|
|
|
|
import io.netty.channel.ChannelHandlerContext;
|
2013-10-13 18:31:26 +02:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
public class PacketWalkieTalkieState extends MekanismPacket
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
|
|
|
public int channel;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-20 22:15:44 +02:00
|
|
|
public PacketWalkieTalkieState(Object... data)
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
|
|
|
channel = (Integer)data[0];
|
|
|
|
}
|
|
|
|
|
2014-03-08 02:00:25 +01:00
|
|
|
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
2013-10-13 18:31:26 +02:00
|
|
|
{
|
2014-03-08 02:00:25 +01:00
|
|
|
int chan = dataStream.readInt();
|
|
|
|
|
2013-10-13 18:31:26 +02:00
|
|
|
ItemStack itemstack = player.getCurrentEquippedItem();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-10-13 18:31:26 +02:00
|
|
|
if(itemstack != null && itemstack.getItem() instanceof ItemWalkieTalkie)
|
|
|
|
{
|
|
|
|
((ItemWalkieTalkie)itemstack.getItem()).setChannel(itemstack, chan);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void write(DataOutputStream dataStream) throws Exception
|
|
|
|
{
|
|
|
|
dataStream.writeInt(channel);
|
|
|
|
}
|
2014-04-20 22:15:44 +02:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public void encodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void decodeInto(ChannelHandlerContext ctx, ByteBuf buffer)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleClientSide(EntityPlayer player)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void handleServerSide(EntityPlayer player)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
2013-10-13 18:31:26 +02:00
|
|
|
}
|