Fixed Packet NPE

This commit is contained in:
Henry Mao 2013-01-08 21:28:32 +08:00
parent 2042a8625c
commit 4d95ce5621
4 changed files with 16 additions and 52 deletions

View file

@ -65,7 +65,7 @@ public class BlockRenderingHandler implements ISimpleBlockRenderingHandler
} }
else if (block.blockID == AssemblyLine.blockArmbot.blockID) 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.glPushMatrix();
GL11.glTranslatef(0.4f, 0.8f, 0f); GL11.glTranslatef(0.4f, 0.8f, 0f);
GL11.glScalef(0.7f, 0.7f, 0.7f); GL11.glScalef(0.7f, 0.7f, 0.7f);

View file

@ -11,11 +11,12 @@ import assemblyline.common.AssemblyLine;
public class RenderArmbot extends TileEntitySpecialRenderer public class RenderArmbot extends TileEntitySpecialRenderer
{ {
public static final ModelArmbot MOEDL = new ModelArmbot(); public static final ModelArmbot MOEDL = new ModelArmbot();
public static final String TEXTURE = "armbot.png";
@Override @Override
public void renderTileEntityAt(TileEntity tileEntity, double x, double y, double z, float var8) 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.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);

View file

@ -113,8 +113,14 @@ public abstract class TileEntityAssemblyNetwork extends TileEntityElectricityRec
this.powerTransferRange = 0; this.powerTransferRange = 0;
this.updatePowerTransferRange(); this.updatePowerTransferRange();
} }
if (FMLCommonHandler.instance().getEffectiveSide() == Side.SERVER)
PacketManager.sendPacketToClients(getDescriptionPacket()); if (!this.worldObj.isRemote)
{
if (this.getDescriptionPacket() != null)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket());
}
}
} }
} }

View file

@ -13,21 +13,20 @@ import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import universalelectricity.core.electricity.ElectricityConnections; import universalelectricity.core.electricity.ElectricityConnections;
import universalelectricity.core.implement.IConductor;
import universalelectricity.core.implement.IJouleStorage; import universalelectricity.core.implement.IJouleStorage;
import universalelectricity.core.vector.Vector3; import universalelectricity.core.vector.Vector3;
import universalelectricity.prefab.TranslationHelper; import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.multiblock.IMultiBlock; import universalelectricity.prefab.multiblock.IMultiBlock;
import universalelectricity.prefab.network.IPacketReceiver; import universalelectricity.prefab.network.IPacketReceiver;
import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
import assemblyline.common.AssemblyLine; import assemblyline.common.AssemblyLine;
import assemblyline.common.machine.TileEntityAssemblyNetwork;
import assemblyline.common.machine.armbot.CommandIdle; import assemblyline.common.machine.armbot.CommandIdle;
import assemblyline.common.machine.armbot.CommandManager; import assemblyline.common.machine.armbot.CommandManager;
import assemblyline.common.machine.encoder.ItemDisk; import assemblyline.common.machine.encoder.ItemDisk;
import com.google.common.io.ByteArrayDataInput; 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. * The items this container contains.
@ -54,56 +53,14 @@ public class TileEntityArmbot extends TileEntityElectricityReceiver implements I
ElectricityConnections.registerConnector(this, EnumSet.of(ForgeDirection.DOWN, ForgeDirection.SOUTH, ForgeDirection.NORTH, ForgeDirection.EAST, ForgeDirection.WEST)); 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.isRunning())
if (!this.worldObj.isRemote)
{ {
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 @Override
public double getVoltage() public double getVoltage()
{ {