Skip to content

Commit

Permalink
Fix empty smeltery trying to drain
Browse files Browse the repository at this point in the history
  • Loading branch information
mDiyo committed Sep 21, 2013
1 parent 19a12b1 commit e57da5a
Showing 1 changed file with 34 additions and 24 deletions.
58 changes: 34 additions & 24 deletions src/tconstruct/blocks/logic/SmelteryLogic.java
Expand Up @@ -349,14 +349,16 @@ else if (PHConstruct.throwableSmeltery && o instanceof EntityItem)
}
}

private void handleItemEntity(EntityItem item)
private void handleItemEntity (EntityItem item)
{
// Clients like to play merry hell with this and cause breakage (we update their inv on syncs)
if (worldObj.isRemote) return;
if (worldObj.isRemote)
return;

item.age = 0;
ItemStack istack = item.getEntityItem();
if (istack.stackSize <= 0) return;
if (istack.stackSize <= 0)
return;

int maxSlot = this.getSizeInventory();
boolean itemDestroyed = false;
Expand All @@ -381,7 +383,8 @@ private void handleItemEntity(EntityItem item)

if (!itemDestroyed)
item.setEntityItemStack(istack);
if (itemAdded) {
if (itemAdded)
{
this.needsUpdate = true;
PacketDispatcher.sendPacketToAllInDimension(getDescriptionPacket(), worldObj.provider.dimensionId);
}
Expand Down Expand Up @@ -928,29 +931,36 @@ public FluidStack drain (int maxDrain, boolean doDrain)
return null;

FluidStack liquid = moltenMetal.get(0);
if (liquid.amount - maxDrain <= 0)
if (liquid != null)
{
FluidStack liq = liquid.copy();
if (doDrain)
if (liquid.amount - maxDrain <= 0)
{
//liquid = null;
moltenMetal.remove(liquid);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
currentLiquid = 0;
needsUpdate = true;
FluidStack liq = liquid.copy();
if (doDrain)
{
//liquid = null;
moltenMetal.remove(liquid);
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
currentLiquid = 0;
needsUpdate = true;
}
return liq;
}
else
{
if (doDrain)
{
liquid.amount -= maxDrain;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
currentLiquid -= maxDrain;
needsUpdate = true;
}
return new FluidStack(liquid.fluidID, maxDrain, liquid.tag);
}
return liq;
}
else
{
if (doDrain)
{
liquid.amount -= maxDrain;
worldObj.markBlockForUpdate(xCoord, yCoord, zCoord);
currentLiquid -= maxDrain;
needsUpdate = true;
}
return new FluidStack(liquid.fluidID, maxDrain, liquid.tag);
return new FluidStack(0, 0);
}
}

Expand All @@ -962,7 +972,7 @@ public int fill (FluidStack resource, boolean doFill)
if (resource.amount + currentLiquid > maxLiquid)
resource.amount = maxLiquid - currentLiquid;
int amount = resource.amount;

if (doFill)
{
if (addMoltenMetal(resource, false))
Expand Down Expand Up @@ -1002,8 +1012,8 @@ public FluidTankInfo getInfo ()
{
return new FluidTankInfo(this);
}
public FluidTankInfo[] getMultiTankInfo()

public FluidTankInfo[] getMultiTankInfo ()
{
FluidTankInfo[] info = new FluidTankInfo[moltenMetal.size() + 1];
for (int i = 0; i < moltenMetal.size(); i++)
Expand Down

0 comments on commit e57da5a

Please sign in to comment.