    001    package cpw.mods.fml.common.network;
    002
    003    import net.minecraft.src.NetHandler;
    004    import net.minecraft.src.INetworkManager;
    005
    006    import com.google.common.io.ByteArrayDataInput;
    007    import com.google.common.io.ByteArrayDataOutput;
    008    import com.google.common.io.ByteStreams;
    009
    010    import cpw.mods.fml.common.FMLCommonHandler;
    011
    012    public class EntitySpawnAdjustmentPacket extends FMLPacket
    013    {
    014
    015        public EntitySpawnAdjustmentPacket()
    016        {
    017            super(Type.ENTITYSPAWNADJUSTMENT);
    018        }
    019
    020        public int entityId;
    021        public int serverX;
    022        public int serverY;
    023        public int serverZ;
    024
    025        @Override
    026        public byte[] generatePacket(Object... data)
    027        {
    028            ByteArrayDataOutput dat = ByteStreams.newDataOutput();
    029            dat.writeInt((Integer) data[0]);
    030            dat.writeInt((Integer) data[1]);
    031            dat.writeInt((Integer) data[2]);
    032            dat.writeInt((Integer) data[3]);
    033            return dat.toByteArray();
    034        }
    035
    036        @Override
    037        public FMLPacket consumePacket(byte[] data)
    038        {
    039            ByteArrayDataInput dat = ByteStreams.newDataInput(data);
    040            entityId = dat.readInt();
    041            serverX = dat.readInt();
    042            serverY = dat.readInt();
    043            serverZ = dat.readInt();
    044            return this;
    045        }
    046
    047        @Override
    048        public void execute(INetworkManager network, FMLNetworkHandler handler, NetHandler netHandler, String userName)
    049        {
    050            FMLCommonHandler.instance().adjustEntityLocationOnClient(this);
    051        }
    052
    053    }