super.updateEntity();
if (!this.worldObj.isRemote)
{
ForgeDirection inputDirection = ForgeDirection.getOrientation(this.getBlockMetadata() + 2);
TileEntity inputTile = VectorHelper.getTileEntityFromSide(this.worldObj, new Vector3(this), inputDirection);
if (inputTile instanceof INetworkProvider)
this.network = ((INetworkProvider) inputTile).getNetwork();
else
this.network = null;
}
if (this.inventory[0] != null && this.energyStored < this.getMaxEnergyStored())
{
if (this.inventory[0].getItem() instanceof IItemElectric)
{
this.setEnergyStored(this.getEnergyStored() + (PowerUtils.UE.discharge(this.inventory[0], PowerConversionUtils.INSTANCE.new UEElectricPack((this.getMaxEnergyStored() - this.getEnergyStored()) / this.getVoltage(), this.getVoltage()), 2).toUEWatts()));
}
else if (this.inventory[0].getItem() instanceof IElectricItem)
{
this.setEnergyStored(this.getEnergyStored() + (PowerUtils.IC2.discharge(this.inventory[0], PowerConversionUtils.INSTANCE.new UEElectricPack((this.getMaxEnergyStored() - this.getEnergyStored()) / this.getVoltage(), this.getVoltage()), 2).toUEWatts()));
}
}
if (this.energyStored >= WATTS_PER_TICK - .0500F)
{
// The left slot contains the item to be processed
if (this.inventory[1] != null && this.canDraw() && (this.processTicks == 0 || this.baseID != this.inventory[1].itemID
|| this.baseMeta != this.inventory[1].getItemDamage()))
{
this.baseID = this.inventory[1].itemID;
this.baseMeta = this.inventory[1].getItemDamage();
this.processTicks = this.getDrawingTime();
this.recipeTicks = this.getDrawingTime();
}
// Checks if the item can be processed and if the drawing time left is
// greater than 0, if so, then draw the item.
if (this.canDraw() && this.processTicks > 0)
{
this.processTicks--;
// When the item is finished drawing
if (this.processTicks < 1)
{
this.drawItem();
this.processTicks = 0;
}
this.energyStored -= WATTS_PER_TICK;
}
else
{
this.processTicks = 0;
}
}
if (!this.worldObj.isRemote)
{
if (this.ticks % 3 == 0 && this.playersUsing > 0)
{
PacketManager.sendPacketToClients(this.getDescriptionPacket(), this.worldObj, new Vector3(this), 12);
}
}
this.energyStored = Math.min(this.energyStored, this.getMaxEnergyStored());
this.energyStored = Math.max(this.energyStored, 0f);