fixed infinite water bug *again*
i think i fixed it this time threw but knowing how its been it might crop up again. Need to clean up my code badly and find a way to recyle code better.
This commit is contained in:
parent
34f2d5572e
commit
df6e890c43
3 changed files with 77 additions and 63 deletions
|
@ -43,6 +43,8 @@ public class ItemGuage extends Item
|
|||
return "guage";
|
||||
}
|
||||
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
if(!par3World.isRemote)
|
||||
{
|
||||
if(par1ItemStack.getItemDamage() == 0)
|
||||
{
|
||||
|
@ -54,20 +56,20 @@ public class ItemGuage extends Item
|
|||
int steam = pipeEntity.getStoredLiquid(type);
|
||||
String typeName = getType(type);
|
||||
String print = "Error";
|
||||
if(steam < 0)
|
||||
if(steam <= 0)
|
||||
{
|
||||
print = "No pressure or Volume";
|
||||
}
|
||||
else
|
||||
{
|
||||
print = typeName +" " + steam + 1*Math.random() +" @ 16PSI";
|
||||
print = typeName +" " + steam +" @ 16PSI";
|
||||
}
|
||||
par2EntityPlayer.addChatMessage(print);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -54,7 +54,8 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
|||
|
||||
|
||||
|
||||
private int getNumSide(ForgeDirection side) {
|
||||
private int getNumSide(ForgeDirection side)
|
||||
{
|
||||
|
||||
if(side == ForgeDirection.DOWN)
|
||||
{
|
||||
|
@ -99,7 +100,7 @@ if(side == ForgeDirection.EAST)
|
|||
if(type == this.type)
|
||||
{
|
||||
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.capacity, 0);
|
||||
this.liquidStored += vol - rejectedVolume;
|
||||
this.liquidStored = Math.min(Math.max((liquidStored + vol - rejectedVolume),0),this.capacity);
|
||||
return rejectedVolume;
|
||||
}
|
||||
return vol;
|
||||
|
@ -175,7 +176,7 @@ if(side == ForgeDirection.EAST)
|
|||
{
|
||||
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,ForgeDirection.getOrientation(i)))
|
||||
{
|
||||
int gainedVolume = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type,5-this.liquidStored, ForgeDirection.getOrientation(i));
|
||||
int gainedVolume = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type,this.capacity-this.liquidStored, ForgeDirection.getOrientation(i));
|
||||
this.onReceiveLiquid(this.type, gainedVolume, ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
|
@ -190,16 +191,24 @@ if(side == ForgeDirection.EAST)
|
|||
*/
|
||||
@Override
|
||||
public int getStoredLiquid(int type)
|
||||
{
|
||||
if(type == this.type)
|
||||
{
|
||||
return this.liquidStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(int type)
|
||||
{
|
||||
if(type == this.type)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
|
|
|
@ -133,7 +133,7 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
|||
{
|
||||
--steamStored;
|
||||
++steamConsumed;
|
||||
if(steamConsumed >= SteamPowerMain.steamOutBoiler)
|
||||
if(steamConsumed >= 10)
|
||||
{
|
||||
++waterStored;
|
||||
steamConsumed = 0;
|
||||
|
@ -321,11 +321,10 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
|||
public int onProduceLiquid(int type, int Vol, ForgeDirection side) {
|
||||
if(type == 1)
|
||||
{
|
||||
if(this.waterStored > 0)
|
||||
if(this.waterStored >= 1)
|
||||
{
|
||||
int rejectedSteam = Math.max(Math.max((this.waterStored - Vol), 0),waterStored);
|
||||
this.waterStored += waterStored - rejectedSteam;
|
||||
return rejectedSteam;
|
||||
this.waterStored--;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
@ -366,6 +365,10 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
|||
{
|
||||
return this.steamStored;
|
||||
}
|
||||
if(type == 1)
|
||||
{
|
||||
return this.waterStored;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue