From 4d95ce56210137c9ddb7cd38eea4271bb1aef66e Mon Sep 17 00:00:00 2001 From: Henry Mao Date: Tue, 8 Jan 2013 21:28:32 +0800 Subject: [PATCH] Fixed Packet NPE --- .../client/render/BlockRenderingHandler.java | 2 +- .../client/render/RenderArmbot.java | 3 +- .../machine/TileEntityAssemblyNetwork.java | 10 +++- .../machine/crafter/TileEntityArmbot.java | 53 ++----------------- 4 files changed, 16 insertions(+), 52 deletions(-) diff --git a/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java b/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java index dc178f284..99639af99 100644 --- a/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java +++ b/src/minecraft/assemblyline/client/render/BlockRenderingHandler.java @@ -65,7 +65,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler } else if (block.blockID == AssemblyLine.blockArmbot.blockID) { - GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + "armbot.png")); + GL11.glBindTexture(GL11.GL_TEXTURE_2D, FMLClientHandler.instance().getClient().renderEngine.getTexture(AssemblyLine.TEXTURE_PATH + RenderArmbot.TEXTURE)); GL11.glPushMatrix(); GL11.glTranslatef(0.4f, 0.8f, 0f); GL11.glScalef(0.7f, 0.7f, 0.7f); diff --git a/src/minecraft/assemblyline/client/render/RenderArmbot.java b/src/minecraft/assemblyline/client/render/RenderArmbot.java index 88a8ecf52..f4abcf199 100644 --- a/src/minecraft/assemblyline/client/render/RenderArmbot.java +++ b/src/minecraft/assemblyline/client/render/RenderArmbot.java @@ -11,11 +11,12 @@ import assemblyline.common.AssemblyLine; public class RenderArmbot extends TileEntitySpecialRenderer { public static final ModelArmbot MOEDL = new ModelArmbot(); + public static final String TEXTURE = "armbot.png"; @Override public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) { - this.bindTextureByName(AssemblyLine.TEXTURE_PATH + "armbot.png"); + this.bindTextureByName(AssemblyLine.TEXTURE_PATH + TEXTURE); GL11.glPushMatrix(); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glScalef(1.0F, -1F, -1F); diff --git a/src/minecraft/assemblyline/common/machine/TileEntityAssemblyNetwork.java b/src/minecraft/assemblyline/common/machine/TileEntityAssemblyNetwork.java index 9e402ed78..a0fb32556 100644 --- a/src/minecraft/assemblyline/common/machine/TileEntityAssemblyNetwork.java +++ b/src/minecraft/assemblyline/common/machine/TileEntityAssemblyNetwork.java @@ -113,8 +113,14 @@ public abstract class TileEntityAssemblyNetwork extends TileEntityElectricityRec this.powerTransferRange = 0; this.updatePowerTransferRange(); } - if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER) - PacketManager.sendPacketToClients(getDescriptionPacket()); + + if (!this.worldObj.isRemote) + { + if (this.getDescriptionPacket() != null) + { + PacketManager.sendPacketToClients(this.getDescriptionPacket()); + } + } } } diff --git a/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java b/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java index 8539f720a..d18a1493a 100644 --- a/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java +++ b/src/minecraft/assemblyline/common/machine/crafter/TileEntityArmbot.java @@ -13,21 +13,20 @@ import net.minecraft.network.packet.Packet250CustomPayload; import net.minecraft.tileentity.TileEntity; import net.minecraftforge.common.ForgeDirection; import universalelectricity.core.electricity.ElectricityConnections; -import universalelectricity.core.implement.IConductor; import universalelectricity.core.implement.IJouleStorage; import universalelectricity.core.vector.Vector3; import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.multiblock.IMultiBlock; import universalelectricity.prefab.network.IPacketReceiver; -import universalelectricity.prefab.tile.TileEntityElectricityReceiver; import assemblyline.common.AssemblyLine; +import assemblyline.common.machine.TileEntityAssemblyNetwork; import assemblyline.common.machine.armbot.CommandIdle; import assemblyline.common.machine.armbot.CommandManager; import assemblyline.common.machine.encoder.ItemDisk; import com.google.common.io.ByteArrayDataInput; -public class TileEntityArmbot extends TileEntityElectricityReceiver implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage +public class TileEntityArmbot extends TileEntityAssemblyNetwork implements IMultiBlock, IInventory, IPacketReceiver, IJouleStorage { /** * The items this container contains. @@ -54,54 +53,12 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.WEST)); } - public void updateEntity() + public void onUpdate() { - super.updateEntity(); - - if (!this.worldObj.isRemote) + if (this.isRunning()) { - for (int i = 0; i < 6; i++) - { - ForgeDirection inputDirection = ForgeDirection.getOrientation(i); - - if (inputDirection != ForgeDirection.UP) - { - TileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection); - - if (inputTile != null) - { - if (inputTile instanceof IConductor) - { - if (this.getJoules() >= this.getMaxJoules()) - { - ((IConductor) inputTile).getNetwork().stopRequesting(this); - } - else - { - ((IConductor) inputTile).getNetwork().startRequesting(this, this.WATT_REQUEST / this.getVoltage(), this.getVoltage()); - this.setJoules(this.getJoules() + ((IConductor) inputTile).getNetwork().consumeElectricity(this).getWatts()); - } - } - } - } - } + this.taskManager.onUpdate(); } - - this.taskManager.onUpdate(); - - if (this.ticks % 5 == 0 && !this.isDisabled() && this.taskManager.hasTasks() && EntityArm != null) - { - this.wattsReceived -= this.WATT_REQUEST; - this.doWork(); - } - } - - /** - * controls the robotic arm into doing a set task - */ - public void doWork() - { - } @Override