Made vanilla furnace stop producing power upon no request

This commit is contained in:
Calclavia 2013-10-10 22:22:36 +08:00
parent 49e6fed4fc
commit 5c5657de1c

View file

@ -52,34 +52,50 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEle
else else
{ {
super.updateEntity(); super.updateEntity();
if (this.doProduce) if (this.doProduce)
{ {
if (this.getStackInSlot(0) == null) if (this.getStackInSlot(0) == null)
{ {
/** boolean hasRequest = false;
* Steal power from furnace.
*/
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
this.furnaceCookTime = 0;
if (this.furnaceBurnTime == 0) for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{ {
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1)); TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
this.decrStackSize(1, 1);
this.furnaceBurnTime = burnTime;
}
if (this.furnaceBurnTime > 0) if (tileEntity instanceof IConductor)
{
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{ {
this.produceUE(direction); if (((IConductor) tileEntity).getNetwork().getRequest(this).getWatts() > 0)
{
if (this.furnaceBurnTime > 0)
{
this.produceUE(direction);
}
hasRequest = true;
break;
}
} }
} }
if (doBlockStateUpdate != this.furnaceBurnTime > 0) if (hasRequest)
{ {
BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); /**
* Steal power from furnace.
*/
boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
if (this.furnaceBurnTime == 0)
{
int burnTime = TileEntityFurnace.getItemBurnTime(this.getStackInSlot(1));
this.decrStackSize(1, 1);
this.furnaceBurnTime = burnTime;
}
if (doBlockStateUpdate != this.furnaceBurnTime > 0)
{
BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
}
} }
} }
} }
@ -93,7 +109,9 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEle
{ {
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS) for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{ {
if (new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj) instanceof IConductor) TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
if (tileEntity instanceof IConductor)
{ {
this.doProduce = true; this.doProduce = true;
return; return;