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";
|
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)
|
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)
|
if(par1ItemStack.getItemDamage() == 0)
|
||||||
{
|
{
|
||||||
|
@ -54,20 +56,20 @@ public class ItemGuage extends Item
|
||||||
int steam = pipeEntity.getStoredLiquid(type);
|
int steam = pipeEntity.getStoredLiquid(type);
|
||||||
String typeName = getType(type);
|
String typeName = getType(type);
|
||||||
String print = "Error";
|
String print = "Error";
|
||||||
if(steam < 0)
|
if(steam <= 0)
|
||||||
{
|
{
|
||||||
print = "No pressure or Volume";
|
print = "No pressure or Volume";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print = typeName +" " + steam + 1*Math.random() +" @ 16PSI";
|
print = typeName +" " + steam +" @ 16PSI";
|
||||||
}
|
}
|
||||||
par2EntityPlayer.addChatMessage(print);
|
par2EntityPlayer.addChatMessage(print);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
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)
|
if(side == ForgeDirection.DOWN)
|
||||||
{
|
{
|
||||||
|
@ -99,7 +100,7 @@ if(side == ForgeDirection.EAST)
|
||||||
if(type == this.type)
|
if(type == this.type)
|
||||||
{
|
{
|
||||||
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.capacity, 0);
|
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 rejectedVolume;
|
||||||
}
|
}
|
||||||
return vol;
|
return vol;
|
||||||
|
@ -175,7 +176,7 @@ if(side == ForgeDirection.EAST)
|
||||||
{
|
{
|
||||||
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,ForgeDirection.getOrientation(i)))
|
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));
|
this.onReceiveLiquid(this.type, gainedVolume, ForgeDirection.getOrientation(i));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,16 +191,24 @@ if(side == ForgeDirection.EAST)
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int getStoredLiquid(int type)
|
public int getStoredLiquid(int type)
|
||||||
|
{
|
||||||
|
if(type == this.type)
|
||||||
{
|
{
|
||||||
return this.liquidStored;
|
return this.liquidStored;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLiquidCapacity(int type)
|
public int getLiquidCapacity(int type)
|
||||||
|
{
|
||||||
|
if(type == this.type)
|
||||||
{
|
{
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads a tile entity from NBT.
|
* Reads a tile entity from NBT.
|
||||||
|
|
|
@ -133,7 +133,7 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
{
|
{
|
||||||
--steamStored;
|
--steamStored;
|
||||||
++steamConsumed;
|
++steamConsumed;
|
||||||
if(steamConsumed >= SteamPowerMain.steamOutBoiler)
|
if(steamConsumed >= 10)
|
||||||
{
|
{
|
||||||
++waterStored;
|
++waterStored;
|
||||||
steamConsumed = 0;
|
steamConsumed = 0;
|
||||||
|
@ -321,11 +321,10 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
public int onProduceLiquid(int type, int Vol, ForgeDirection side) {
|
public int onProduceLiquid(int type, int Vol, ForgeDirection side) {
|
||||||
if(type == 1)
|
if(type == 1)
|
||||||
{
|
{
|
||||||
if(this.waterStored > 0)
|
if(this.waterStored >= 1)
|
||||||
{
|
{
|
||||||
int rejectedSteam = Math.max(Math.max((this.waterStored - Vol), 0),waterStored);
|
this.waterStored--;
|
||||||
this.waterStored += waterStored - rejectedSteam;
|
return 1;
|
||||||
return rejectedSteam;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -366,6 +365,10 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
{
|
{
|
||||||
return this.steamStored;
|
return this.steamStored;
|
||||||
}
|
}
|
||||||
|
if(type == 1)
|
||||||
|
{
|
||||||
|
return this.waterStored;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue