Mekanism-tilera-Edition/src/main/java/mekanism/common/network/PacketDigitUpdate.java

69 lines
1.4 KiB
Java
Raw Normal View History

package mekanism.common.network;
import java.io.DataOutputStream;
import mekanism.common.item.ItemPortableTeleporter;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
import com.google.common.io.ByteArrayDataInput;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
public class PacketDigitUpdate extends MekanismPacket
{
public int index;
public int digit;
public PacketDigitUpdate(int ind, int dig)
{
index = ind;
digit = dig;
}
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
{
int index = dataStream.readInt();
int digit = dataStream.readInt();
ItemStack currentStack = player.getCurrentEquippedItem();
if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter)
{
ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem();
item.setDigit(currentStack, index, digit);
}
}
public void write(DataOutputStream dataStream) throws Exception
{
dataStream.writeInt(index);
dataStream.writeInt(digit);
}
@Override
public void write(ChannelHandlerContext ctx, ByteBuf buffer)
{
}
@Override
public void read(ChannelHandlerContext ctx, ByteBuf buffer)
{
}
@Override
public void handleClientSide(EntityPlayer player)
{
}
@Override
public void handleServerSide(EntityPlayer player)
{
}
}