2013-06-13 23:37:30 +02:00
|
|
|
package mekanism.common.network;
|
|
|
|
|
|
|
|
import java.io.DataOutputStream;
|
2013-06-15 00:25:09 +02:00
|
|
|
import java.util.ArrayList;
|
2013-06-13 23:37:30 +02:00
|
|
|
|
2013-12-20 22:09:09 +01:00
|
|
|
import mekanism.api.Coord4D;
|
2013-06-13 23:37:30 +02:00
|
|
|
import mekanism.common.ITileNetwork;
|
|
|
|
import mekanism.common.PacketHandler;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
|
|
import net.minecraft.tileentity.TileEntity;
|
|
|
|
import net.minecraft.world.World;
|
|
|
|
|
|
|
|
import com.google.common.io.ByteArrayDataInput;
|
|
|
|
|
|
|
|
public class PacketTileEntity implements IMekanismPacket
|
|
|
|
{
|
2013-12-20 22:09:09 +01:00
|
|
|
public Coord4D object3D;
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
public ArrayList parameters;
|
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 "TileEntity";
|
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-12-20 22:09:09 +01:00
|
|
|
object3D = (Coord4D)data[0];
|
2013-06-15 00:25:09 +02:00
|
|
|
parameters = (ArrayList)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
|
|
|
|
public void read(ByteArrayDataInput dataStream, EntityPlayer player, World world) throws Exception
|
|
|
|
{
|
|
|
|
int x = dataStream.readInt();
|
|
|
|
int y = dataStream.readInt();
|
|
|
|
int z = dataStream.readInt();
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2014-04-20 05:34:19 +02:00
|
|
|
TileEntity tileEntity = world.getTileEntity(x, y, z);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-13 23:37:30 +02:00
|
|
|
if(tileEntity instanceof ITileNetwork)
|
|
|
|
{
|
|
|
|
((ITileNetwork)tileEntity).handlePacketData(dataStream);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void write(DataOutputStream dataStream) throws Exception
|
|
|
|
{
|
|
|
|
dataStream.writeInt(object3D.xCoord);
|
|
|
|
dataStream.writeInt(object3D.yCoord);
|
|
|
|
dataStream.writeInt(object3D.zCoord);
|
2014-03-08 02:00:25 +01:00
|
|
|
|
2013-06-15 00:25:09 +02:00
|
|
|
PacketHandler.encode(new Object[] {parameters}, dataStream);
|
2013-06-13 23:37:30 +02:00
|
|
|
}
|
|
|
|
}
|