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
|
@ -44,30 +44,32 @@ public class ItemGuage extends Item
|
||||||
}
|
}
|
||||||
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(par1ItemStack.getItemDamage() == 0)
|
if(!par3World.isRemote)
|
||||||
{
|
{
|
||||||
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
if(par1ItemStack.getItemDamage() == 0)
|
||||||
if(blockEntity instanceof TileEntityPipe)
|
{
|
||||||
{
|
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
||||||
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
if(blockEntity instanceof TileEntityPipe)
|
||||||
int type = pipeEntity.getType();
|
{
|
||||||
int steam = pipeEntity.getStoredLiquid(type);
|
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
||||||
String typeName = getType(type);
|
int type = pipeEntity.getType();
|
||||||
String print = "Error";
|
int steam = pipeEntity.getStoredLiquid(type);
|
||||||
if(steam < 0)
|
String typeName = getType(type);
|
||||||
{
|
String print = "Error";
|
||||||
print = "No pressure or Volume";
|
if(steam <= 0)
|
||||||
}
|
{
|
||||||
else
|
print = "No pressure or Volume";
|
||||||
{
|
}
|
||||||
print = typeName +" " + steam + 1*Math.random() +" @ 16PSI";
|
else
|
||||||
}
|
{
|
||||||
par2EntityPlayer.addChatMessage(print);
|
print = typeName +" " + steam +" @ 16PSI";
|
||||||
return true;
|
}
|
||||||
}
|
par2EntityPlayer.addChatMessage(print);
|
||||||
}
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -54,32 +54,33 @@ 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)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if(side == ForgeDirection.UP)
|
if(side == ForgeDirection.UP)
|
||||||
{
|
{
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if(side == ForgeDirection.NORTH)
|
if(side == ForgeDirection.NORTH)
|
||||||
{
|
{
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
if(side == ForgeDirection.SOUTH)
|
if(side == ForgeDirection.SOUTH)
|
||||||
{
|
{
|
||||||
return 3;
|
return 3;
|
||||||
}
|
}
|
||||||
if(side == ForgeDirection.WEST)
|
if(side == ForgeDirection.WEST)
|
||||||
{
|
{
|
||||||
return 4;
|
return 4;
|
||||||
}
|
}
|
||||||
if(side == ForgeDirection.EAST)
|
if(side == ForgeDirection.EAST)
|
||||||
{
|
{
|
||||||
return 5;
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -98,9 +99,9 @@ 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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -191,14 +192,22 @@ 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)
|
||||||
{
|
{
|
||||||
return 5;
|
if(type == this.type)
|
||||||
|
{
|
||||||
|
return 5;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -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;
|
||||||
|
@ -344,9 +343,9 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
|
public int onReceiveLiquid(int type, int vol, ForgeDirection side) {
|
||||||
if(type == 0)
|
if(type == 0)
|
||||||
{
|
{
|
||||||
int rejectedSteam = Math.max((this.steamStored + vol) - 100, 0);
|
int rejectedSteam = Math.max((this.steamStored + vol) - 100, 0);
|
||||||
this.steamStored += vol - rejectedSteam;
|
this.steamStored += vol - rejectedSteam;
|
||||||
return rejectedSteam;
|
return rejectedSteam;
|
||||||
}
|
}
|
||||||
return vol;
|
return vol;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +363,11 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
public int getStoredLiquid(int type) {
|
public int getStoredLiquid(int type) {
|
||||||
if(type == 0)
|
if(type == 0)
|
||||||
{
|
{
|
||||||
return this.steamStored;
|
return this.steamStored;
|
||||||
|
}
|
||||||
|
if(type == 1)
|
||||||
|
{
|
||||||
|
return this.waterStored;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -373,7 +376,7 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
public int getLiquidCapacity(int type) {
|
public int getLiquidCapacity(int type) {
|
||||||
if(type == 0)
|
if(type == 0)
|
||||||
{
|
{
|
||||||
return 100;
|
return 100;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue