Search in sources :

Example 1 with PacketDynamicInventory

use of micdoodle8.mods.galacticraft.core.network.PacketDynamicInventory in project Galacticraft by micdoodle8.

the class EntityLanderBase method readNetworkedData.

@Override
public void readNetworkedData(ByteBuf buffer) {
    try {
        if (this.worldObj.isRemote) {
            if (!this.hasReceivedPacket) {
                GalacticraftCore.packetPipeline.sendToServer(new PacketDynamic(this));
                this.hasReceivedPacket = true;
            }
            int cargoLength = buffer.readInt();
            if (this.containedItems == null || this.containedItems.length == 0) {
                this.containedItems = new ItemStack[cargoLength];
                GalacticraftCore.packetPipeline.sendToServer(new PacketDynamicInventory(this));
            }
            this.fuelTank.setFluid(new FluidStack(GCFluids.fluidFuel, buffer.readInt()));
            this.shouldMoveServer = buffer.readBoolean();
            // Check has correct rider on client
            int shouldBeMountedId = buffer.readInt();
            if (this.riddenByEntity == null) {
                if (shouldBeMountedId > -1) {
                    Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
                    if (e != null) {
                        if (e.dimension != this.dimension) {
                            if (e instanceof EntityPlayer) {
                                e = WorldUtil.forceRespawnClient(this.dimension, e.worldObj.getDifficulty().getDifficultyId(), e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(), ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                                e.mountEntity(this);
                                this.syncAdjustFlag = true;
                            }
                        } else {
                            e.mountEntity(this);
                            this.syncAdjustFlag = true;
                        }
                    }
                }
            } else if (this.riddenByEntity.getEntityId() != shouldBeMountedId) {
                if (shouldBeMountedId == -1) {
                    this.riddenByEntity.mountEntity(null);
                } else {
                    Entity e = FMLClientHandler.instance().getWorldClient().getEntityByID(shouldBeMountedId);
                    if (e != null) {
                        if (e.dimension != this.dimension) {
                            if (e instanceof EntityPlayer) {
                                e = WorldUtil.forceRespawnClient(this.dimension, e.worldObj.getDifficulty().getDifficultyId(), e.worldObj.getWorldInfo().getTerrainType().getWorldTypeName(), ((EntityPlayerMP) e).theItemInWorldManager.getGameType().getID());
                                e.mountEntity(this);
                                this.syncAdjustFlag = true;
                            }
                        } else {
                            e.mountEntity(this);
                            this.syncAdjustFlag = true;
                        }
                    }
                }
            }
        } else {
            this.shouldMoveClient = buffer.readBoolean();
        }
    } catch (final Exception e) {
        e.printStackTrace();
    }
}
Also used : Entity(net.minecraft.entity.Entity) FluidStack(net.minecraftforge.fluids.FluidStack) PacketDynamicInventory(micdoodle8.mods.galacticraft.core.network.PacketDynamicInventory) EntityPlayer(net.minecraft.entity.player.EntityPlayer) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) PacketDynamic(micdoodle8.mods.galacticraft.core.network.PacketDynamic)

Aggregations

PacketDynamic (micdoodle8.mods.galacticraft.core.network.PacketDynamic)1 PacketDynamicInventory (micdoodle8.mods.galacticraft.core.network.PacketDynamicInventory)1 Entity (net.minecraft.entity.Entity)1 EntityPlayer (net.minecraft.entity.player.EntityPlayer)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 FluidStack (net.minecraftforge.fluids.FluidStack)1