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();
}
}
Aggregations