2013-06-13 23:37:30 +02:00
|
|
|
package mekanism.common.network;
|
|
|
|
|
|
|
|
import java.io.DataOutputStream;
|
|
|
|
|
2013-08-27 00:49:32 +02:00
|
|
|
import mekanism.common.item.ItemPortableTeleporter;
|
2013-06-13 23:37:30 +02:00
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import com.google.common.io.ByteArrayDataInput;
|
|
|
|
|
|
|
|
public class PacketDigitUpdate implements IMekanismPacket
|
|
|
|
{
|
|
|
|
public int index;
|
|
|
|
public int digit;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public String getName()
|
2013-06-13 23:37:30 +02:00
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
return "DigitUpdate";
|
2013-06-13 23:37:30 +02:00
|
|
|
}
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-13 23:37:30 +02:00
|
|
|
@Override
|
2013-06-15 00:25:09 +02:00
|
|
|
public IMekanismPacket setParams(Object... data)
|
2013-06-13 23:37:30 +02:00
|
|
|
{
|
2013-06-15 00:25:09 +02:00
|
|
|
index = (Integer)data[0];
|
|
|
|
digit = (Integer)data[1];
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
return this;
|
2013-06-13 23:37:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2014-03-08 02:00:25 +01:00
|
|
|
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
2013-06-13 23:37:30 +02:00
|
|
|
{
|
|
|
|
int index = dataStream.readInt();
|
|
|
|
int digit = dataStream.readInt();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-13 23:37:30 +02:00
|
|
|
ItemStack currentStack = player.getCurrentEquippedItem();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-13 23:37:30 +02:00
|
|
|
if(currentStack != null && currentStack.getItem() instanceof ItemPortableTeleporter)
|
|
|
|
{
|
|
|
|
ItemPortableTeleporter item = (ItemPortableTeleporter)currentStack.getItem();
|
|
|
|
item.setDigit(currentStack, index, digit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(DataOutputStream dataStream) throws Exception
|
|
|
|
{
|
|
|
|
dataStream.writeInt(index);
|
|
|
|
dataStream.writeInt(digit);
|
|
|
|
}
|
|
|
|
}
|