Change boiler to use IHeatProducer
Boiler originaly uses this to gain heat to boil water. Due to lack of use i moved it too direct heat gain from fireBox. Now i've add the heat api to basic pipes and changes boiler to also accept lava souce as a heat provider at 10*random*tickRate min 0 max 100 heat gain.
This commit is contained in:
parent
88ee4ca306
commit
1b6e69e7a5
5 changed files with 37 additions and 23 deletions
|
@ -75,11 +75,10 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
//cause the block to update itself every tick needs to be change to .5 seconds to reduce load
|
//cause the block to update itself every tick needs to be change to .5 seconds to reduce load
|
||||||
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||||
count++;
|
count++;
|
||||||
if(count >= 10 || intiUpdate && !this.worldObj.isRemote)
|
if(count >= 10 && !this.worldObj.isRemote)
|
||||||
{
|
{
|
||||||
PacketManager.sendTileEntityPacket(this, "Pipes", new Object[]{this.type.ordinal()});
|
PacketManager.sendTileEntityPacket(this, "Pipes", new Object[]{this.type.ordinal()});
|
||||||
count = 0;
|
count = 0;
|
||||||
intiUpdate = false;
|
|
||||||
|
|
||||||
|
|
||||||
int connectedUnits = 0;
|
int connectedUnits = 0;
|
||||||
|
@ -100,7 +99,8 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
averagePresure2 += ((ILiquidProducer)connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i));
|
averagePresure2 += ((ILiquidProducer)connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i));
|
||||||
producers++;
|
producers++;
|
||||||
}
|
}
|
||||||
}else
|
}
|
||||||
|
|
||||||
if(connectedBlocks[i] instanceof TileEntityPipe)
|
if(connectedBlocks[i] instanceof TileEntityPipe)
|
||||||
{
|
{
|
||||||
pipes ++;
|
pipes ++;
|
||||||
|
@ -112,13 +112,6 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
{
|
{
|
||||||
this.hPressure = pPressure;
|
this.hPressure = pPressure;
|
||||||
}
|
}
|
||||||
}else
|
|
||||||
if(connectedBlocks[i] instanceof ILiquidConsumer)
|
|
||||||
{
|
|
||||||
if(this.presure <= 1)
|
|
||||||
{
|
|
||||||
this.hPressure = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -154,14 +147,26 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
{
|
{
|
||||||
int transferVolumeAmount = 0; //amount to be moved
|
int transferVolumeAmount = 0; //amount to be moved
|
||||||
ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]);
|
ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]);
|
||||||
|
if(connectedBlocks[i] instanceof TileEntityPipe)
|
||||||
transferVolumeAmount = this.liquidStored;
|
{
|
||||||
|
if(((TileEntityPipe)connectedBlocks[i]).presure < this.presure)
|
||||||
|
{
|
||||||
|
transferVolumeAmount = this.liquidStored;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transferVolumeAmount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
transferVolumeAmount = this.liquidStored;
|
||||||
|
}
|
||||||
|
|
||||||
int rejectedVolume = connectedConsumer.onReceiveLiquid(this.type,transferVolumeAmount, ForgeDirection.getOrientation(i));
|
int rejectedVolume = connectedConsumer.onReceiveLiquid(this.type,transferVolumeAmount, ForgeDirection.getOrientation(i));
|
||||||
this.liquidStored = Math.max(Math.min(this.liquidStored - transferVolumeAmount + rejectedVolume, 5), 0);
|
this.liquidStored = Math.max(Math.min(this.liquidStored - transferVolumeAmount + rejectedVolume, this.capacity), 0);
|
||||||
}
|
}
|
||||||
}
|
}else
|
||||||
|
|
||||||
if(connectedBlocks[i] instanceof ILiquidProducer && this.liquidStored < this.getLiquidCapacity(type))
|
if(connectedBlocks[i] instanceof ILiquidProducer && this.liquidStored < this.getLiquidCapacity(type))
|
||||||
{
|
{
|
||||||
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,ForgeDirection.getOrientation(i)))
|
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,ForgeDirection.getOrientation(i)))
|
||||||
|
@ -196,7 +201,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
{
|
{
|
||||||
if(type == this.type)
|
if(type == this.type)
|
||||||
{
|
{
|
||||||
return 5;
|
return this.capacity;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package steampower.api;
|
package basicpipes.pipes.api;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules.
|
* The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules.
|
|
@ -1,4 +1,4 @@
|
||||||
package steampower.api;
|
package basicpipes.pipes.api;
|
||||||
|
|
||||||
|
|
||||||
public interface IHeatProducer
|
public interface IHeatProducer
|
|
@ -1,4 +1,6 @@
|
||||||
package steampower.boiler;
|
package steampower.boiler;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
import net.minecraft.src.Block;
|
import net.minecraft.src.Block;
|
||||||
import net.minecraft.src.EntityPlayer;
|
import net.minecraft.src.EntityPlayer;
|
||||||
import net.minecraft.src.Item;
|
import net.minecraft.src.Item;
|
||||||
|
@ -13,6 +15,7 @@ import steampower.TileEntityMachine;
|
||||||
import steampower.TradeHelper;
|
import steampower.TradeHelper;
|
||||||
import steampower.burner.TileEntityFireBox;
|
import steampower.burner.TileEntityFireBox;
|
||||||
import universalelectricity.network.IPacketReceiver;
|
import universalelectricity.network.IPacketReceiver;
|
||||||
|
import basicpipes.pipes.api.IHeatProducer;
|
||||||
import basicpipes.pipes.api.ILiquidConsumer;
|
import basicpipes.pipes.api.ILiquidConsumer;
|
||||||
import basicpipes.pipes.api.ILiquidProducer;
|
import basicpipes.pipes.api.ILiquidProducer;
|
||||||
import basicpipes.pipes.api.Liquid;
|
import basicpipes.pipes.api.Liquid;
|
||||||
|
@ -49,13 +52,14 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
|
||||||
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
||||||
int steamMax = 140;
|
int steamMax = 140;
|
||||||
public boolean isBeingHeated = false;
|
public boolean isBeingHeated = false;
|
||||||
|
private Random random = new Random();
|
||||||
public String getInvName()
|
public String getInvName()
|
||||||
{
|
{
|
||||||
return "container.boiler";
|
return "container.boiler";
|
||||||
}
|
}
|
||||||
public Object[] getSendData()
|
public Object[] getSendData()
|
||||||
{
|
{
|
||||||
return new Object[]{(int)facing,(int)RunTime,(int)energyStore,(int)waterStored,
|
return new Object[]{(int)RunTime,(int)energyStore,(int)waterStored,
|
||||||
(int)steamStored,(int)heatStored,(int)hullHeat,(int)heatTick};
|
(int)steamStored,(int)heatStored,(int)hullHeat,(int)heatTick};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +69,7 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
|
||||||
ByteArrayDataInput dataStream) {
|
ByteArrayDataInput dataStream) {
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
facing = dataStream.readInt();
|
|
||||||
RunTime = dataStream.readInt();
|
RunTime = dataStream.readInt();
|
||||||
energyStore = dataStream.readInt();
|
energyStore = dataStream.readInt();
|
||||||
waterStored = dataStream.readInt();
|
waterStored = dataStream.readInt();
|
||||||
|
@ -170,10 +174,14 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
|
||||||
|
|
||||||
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
|
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
|
||||||
this.isBeingHeated = false;
|
this.isBeingHeated = false;
|
||||||
if(blockE instanceof TileEntityFireBox)
|
if(blockE instanceof IHeatProducer)
|
||||||
{
|
{
|
||||||
this.isBeingHeated = true;
|
this.isBeingHeated = true;
|
||||||
heatStored = (int) Math.min((heatStored + ((TileEntityFireBox)blockE).onProduceHeat(SteamPowerMain.fireOutput*getTickInterval(), 1)), heatMax);
|
heatStored = (int) Math.min((heatStored + ((IHeatProducer)blockE).onProduceHeat(SteamPowerMain.fireOutput*getTickInterval(), 1)), heatMax);
|
||||||
|
}
|
||||||
|
else if(worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.lavaStill.blockID)
|
||||||
|
{
|
||||||
|
heatStored += (int) Math.min((int)(random.nextDouble()*10)*getTickInterval(), heatMax);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
super.onUpdate(watts, voltage, side);
|
super.onUpdate(watts, voltage, side);
|
||||||
|
|
|
@ -13,10 +13,11 @@ import net.minecraftforge.common.ISidedInventory;
|
||||||
import steampower.SteamPowerMain;
|
import steampower.SteamPowerMain;
|
||||||
import steampower.TileEntityMachine;
|
import steampower.TileEntityMachine;
|
||||||
import steampower.TradeHelper;
|
import steampower.TradeHelper;
|
||||||
import steampower.api.IHeatProducer;
|
|
||||||
import steampower.boiler.TileEntityBoiler;
|
import steampower.boiler.TileEntityBoiler;
|
||||||
import universalelectricity.network.IPacketReceiver;
|
import universalelectricity.network.IPacketReceiver;
|
||||||
|
|
||||||
|
import basicpipes.pipes.api.IHeatProducer;
|
||||||
|
|
||||||
import com.google.common.io.ByteArrayDataInput;
|
import com.google.common.io.ByteArrayDataInput;
|
||||||
|
|
||||||
public class TileEntityFireBox extends TileEntityMachine implements IPacketReceiver,IInventory, ISidedInventory, IHeatProducer
|
public class TileEntityFireBox extends TileEntityMachine implements IPacketReceiver,IInventory, ISidedInventory, IHeatProducer
|
||||||
|
|
Loading…
Reference in a new issue