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,15 +52,38 @@ 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;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(direction).getTileEntity(this.worldObj);
if (tileEntity instanceof IConductor)
{
if (((IConductor) tileEntity).getNetwork().getRequest(this).getWatts() > 0)
{
if (this.furnaceBurnTime > 0)
{
this.produceUE(direction);
}
hasRequest = true;
break;
}
}
}
if (hasRequest)
{ {
/** /**
* Steal power from furnace. * Steal power from furnace.
*/ */
boolean doBlockStateUpdate = this.furnaceBurnTime > 0; boolean doBlockStateUpdate = this.furnaceBurnTime > 0;
this.furnaceCookTime = 0;
if (this.furnaceBurnTime == 0) if (this.furnaceBurnTime == 0)
{ {
@ -69,14 +92,6 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEle
this.furnaceBurnTime = burnTime; this.furnaceBurnTime = burnTime;
} }
if (this.furnaceBurnTime > 0)
{
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
this.produceUE(direction);
}
}
if (doBlockStateUpdate != this.furnaceBurnTime > 0) if (doBlockStateUpdate != this.furnaceBurnTime > 0)
{ {
BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord); BlockFurnace.updateFurnaceBlockState(this.furnaceBurnTime > 0, this.worldObj, this.xCoord, this.yCoord, this.zCoord);
@ -85,6 +100,7 @@ public class TileEntityAdvancedFurnace extends TileEntityFurnace implements IEle
} }
} }
} }
}
/** /**
* Checks if the furnace should produce power. * Checks if the furnace should produce power.
@ -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;