bug fixes, bugs fixes, and ninja update

suprised how long it too someone to noticed the major bugs i fixed.
Guess i need to play my own mods more and find the bugs myself ;/.
Fixed pipes again
Fixed boiler & LiquidTank liquid sharing system
Added a way for pipes to pump to tanks up a boiler chain
Fixed Boiler GUI
Fixed most machines in general (packets stopped being sent)
pre implemented use of Liquid tank in place of boiler's internal storage
tanks
storage tanks act as pumps on sides, Top for gases, bottom for liquids.
Added crafting for lava, water,steam.fuel,and oil tanks.
Made 4 iron the default tank receipe, and 4 bronze optional will change
out later.
This commit is contained in:
Rseifert 2012-10-19 01:38:53 -04:00
parent fccf7d2f29
commit 64179b0e17
20 changed files with 458 additions and 639 deletions

View file

@ -31,7 +31,7 @@ import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.network.NetworkMod; import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "basicPipes", name = "Basic Pipes", version = "1.7",dependencies = "after:UniversalElectricity") @Mod(modid = "basicPipes", name = "Basic Pipes", version = "1.9",dependencies = "after:UniversalElectricity")
@NetworkMod(channels = { "Pipes" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) @NetworkMod(channels = { "Pipes" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
public class BasicPipesMain{ public class BasicPipesMain{
@ -143,6 +143,16 @@ public class BasicPipesMain{
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,4), new Object[] { new ItemStack(parts, 1,1),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,11)}); GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,4), new Object[] { new ItemStack(parts, 1,1),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,11)});
GameRegistry.addRecipe(new ItemStack(parts, 1,7), new Object[] { "T@T", 'T',new ItemStack(parts,1,0),'@',Block.lever});//valve GameRegistry.addRecipe(new ItemStack(parts, 1,7), new Object[] { "T@T", 'T',new ItemStack(parts,1,0),'@',Block.lever});//valve
GameRegistry.addRecipe(new ItemStack(parts, 1,6), new Object[] { " @ ","@ @"," @ ", '@',Item.ingotIron});//tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1,0), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,15)});
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1,1), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,4)});
//lava TODO change to use obby pipe and nether items
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1,2), new Object[] { new ItemStack(parts, 1,6),Block.obsidian,Block.obsidian,Block.obsidian,Block.obsidian});
//oil
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1,3), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,0)});
//fuel
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1,4), new Object[] { new ItemStack(parts, 1,6),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,11)});
try{ try{
GameRegistry.addRecipe(new ItemStack(parts, 2,0), new Object[] { "@@@", '@',BasicComponents.itemBronzeIngot});//bronze tube GameRegistry.addRecipe(new ItemStack(parts, 2,0), new Object[] { "@@@", '@',BasicComponents.itemBronzeIngot});//bronze tube
//steam //steam
@ -164,7 +174,7 @@ public class BasicPipesMain{
{ {
System.out.print("UE based recipes not loaded"); System.out.print("UE based recipes not loaded");
//secondary boiler tank //secondary boiler tank
GameRegistry.addRecipe(new ItemStack(parts, 1,6), new Object[] { " @ ","@ @"," @ ", '@',Item.ingotIron});//tank
//steam //steam
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,0), new Object[] { new ItemStack(parts, 1,1),new ItemStack(parts, 1,4)}); GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,0), new Object[] { new ItemStack(parts, 1,1),new ItemStack(parts, 1,4)});
} }

View file

@ -6,8 +6,10 @@ import universalelectricity.network.IPacketReceiver;
import universalelectricity.network.PacketManager; import universalelectricity.network.PacketManager;
import universalelectricity.prefab.Vector3; import universalelectricity.prefab.Vector3;
import basicpipes.BasicPipesMain; import basicpipes.BasicPipesMain;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.pipes.api.ILiquidConsumer; import basicpipes.pipes.api.ILiquidConsumer;
import basicpipes.pipes.api.ILiquidProducer; import basicpipes.pipes.api.ILiquidProducer;
import basicpipes.pipes.api.IStorageTank;
import basicpipes.pipes.api.Liquid; import basicpipes.pipes.api.Liquid;
import basicpipes.pipes.api.MHelper; import basicpipes.pipes.api.MHelper;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
@ -20,7 +22,7 @@ import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class TileEntityLTank extends TileEntity implements ILiquidConsumer,ILiquidProducer,IPacketReceiver{ public class TileEntityLTank extends TileEntity implements IStorageTank,ILiquidProducer,IPacketReceiver{
public TileEntity[] cc = {null,null,null,null,null,null}; public TileEntity[] cc = {null,null,null,null,null,null};
public Liquid type = Liquid.DEFUALT; public Liquid type = Liquid.DEFUALT;
public int LStored = 0; public int LStored = 0;
@ -31,13 +33,13 @@ private int count2 = 0;
private boolean firstUpdate = true; private boolean firstUpdate = true;
public void updateEntity() public void updateEntity()
{ {
if(++count >= 10) if(++count >= 5)
{ {
count = 0; count = 0;
this.cc = MHelper.getSourounding(this); this.cc = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
MHelper.shareLiquid(this, type, LStored); MHelper.shareLiquid(worldObj,xCoord, yCoord, zCoord,this.LStored,this.getLiquidCapacity(type), type);
if(firstUpdate ||(this.LStored != pLStored)|| count2 >= 100) if(firstUpdate ||(this.LStored != pLStored)|| count2 >= 100)
{ {
count2 = 0; count2 = 0;
@ -70,11 +72,29 @@ public void readFromNBT(NBTTagCompound nbt)
@Override @Override
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side) public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side)
{ {
if(type == this.type) if(type == this.type)
{
if(this.LStored < this.getLiquidCapacity(this.type))
{ {
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.LMax, 0); int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.LMax, 0);
this.LStored = Math.min(Math.max((LStored + vol - rejectedVolume),0),this.LMax); this.LStored = Math.min(Math.max((LStored + vol - rejectedVolume),0),this.LMax);
return rejectedVolume; return rejectedVolume;
}else
{
TileEntity te = null;
if(this.type.isGas)
{
worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord);
}else
{
worldObj.getBlockTileEntity(xCoord, yCoord-1, zCoord);
}
if( te instanceof IStorageTank)
{
return ((IStorageTank)te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN);
}
}
} }
return vol; return vol;
} }
@ -121,11 +141,11 @@ public Liquid getType() {
@Override @Override
public int onProduceLiquid(Liquid type, int vol, ForgeDirection side) { public int onProduceLiquid(Liquid type, int vol, ForgeDirection side) {
if(type == this.type) if(type == this.type && this.LStored > 1 && vol > 0)
{ {
int aVol = Math.max(((this.getStoredLiquid(type) - vol) + this.LMax)-vol, 0); //TODO correct / do math for
this.LStored = Math.min(Math.max((LStored - aVol),0),this.LMax); LStored--;
return aVol; return 1;
} }
return 0; return 0;
} }
@ -150,11 +170,11 @@ public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
public boolean canProducePresure(Liquid type, ForgeDirection side) { public boolean canProducePresure(Liquid type, ForgeDirection side) {
if(type == this.type) if(type == this.type)
{ {
if(this.type.isGas && side == ForgeDirection.UP) if(this.type.isGas && side == ForgeDirection.DOWN)
{ {
return true; return true;
} }
if(!this.type.isGas && side == ForgeDirection.DOWN) if(!this.type.isGas && side == ForgeDirection.UP)
{ {
return true; return true;
} }
@ -165,16 +185,9 @@ public boolean canProducePresure(Liquid type, ForgeDirection side) {
@Override @Override
public int presureOutput(Liquid type, ForgeDirection side) { public int presureOutput(Liquid type, ForgeDirection side) {
if(type == this.type) if(type == this.type)
{
if(this.type.isGas && side == ForgeDirection.UP)
{ {
return this.type.defaultPresure; return this.type.defaultPresure;
} }
if(!this.type.isGas && side == ForgeDirection.DOWN)
{
return this.type.defaultPresure;
}
}
return 0; return 0;
} }

View file

@ -35,31 +35,6 @@ public class BlockPipe extends BlockContainer
public void onBlockAdded(World world, int x, int y, int z) public void onBlockAdded(World world, int x, int y, int z)
{ {
super.onBlockAdded(world, x, y, z); super.onBlockAdded(world, x, y, z);
this.updateConductorTileEntity(world, x, y, z);
}
public static TileEntity getLiquidUnit(World world, int x, int y, int z, ForgeDirection side,Liquid type)
{
//Check if the designated block is a UE Unit - producer, consumer or a conductor
TileEntity tileEntity = world.getBlockTileEntity(x+side.offsetX, y+side.offsetY, z+side.offsetZ);
TileEntity returnValue = null;
if(tileEntity instanceof ILiquidConsumer)
{
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(type,side))
{
returnValue = tileEntity;
}
}
if (tileEntity instanceof ILiquidProducer)
{
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,side))
{
returnValue = tileEntity;
}
}
return returnValue;
} }
/** /**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
@ -69,7 +44,6 @@ public class BlockPipe extends BlockContainer
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID) public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{ {
super.onNeighborBlockChange(world, x, y, z, blockID); super.onNeighborBlockChange(world, x, y, z, blockID);
this.updateConductorTileEntity(world, x, y, z);
} }
@Override @Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4) public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
@ -82,18 +56,6 @@ public class BlockPipe extends BlockContainer
{ {
return true; return true;
} }
public static void updateConductorTileEntity(World world, int x, int y, int z)
{
for(int i = 0; i < 6; i++)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if(tileEntity instanceof TileEntityPipe)
{
((TileEntityPipe) tileEntity).addConnection(getLiquidUnit(world, x, y, z,
ForgeDirection.getOrientation(i), ((TileEntityPipe) tileEntity).getType()), ForgeDirection.getOrientation(i));
}
}
}
@Override @Override
public TileEntity createNewTileEntity(World var1) { public TileEntity createNewTileEntity(World var1) {

View file

@ -1,18 +1,18 @@
package basicpipes.conductors; package basicpipes.conductors;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import steampower.turbine.TileEntitySteamPiston; import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemStack;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import basicpipes.BasicPipesMain; import basicpipes.BasicPipesMain;
import basicpipes.LTanks.TileEntityLTank; import basicpipes.LTanks.TileEntityLTank;
import basicpipes.pipes.api.IMechanical; import basicpipes.pipes.api.IMechanical;
import basicpipes.pipes.api.Liquid; import basicpipes.pipes.api.Liquid;
import net.minecraft.src.*;
import net.minecraftforge.common.ForgeDirection;
public class ItemGuage extends Item public class ItemGuage extends Item
{ {
private int spawnID; private int spawnID;

View file

@ -12,6 +12,7 @@ import universalelectricity.prefab.Vector3;
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;
import basicpipes.pipes.api.MHelper;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacketReceiver public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacketReceiver
@ -19,51 +20,92 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
protected Liquid type = Liquid.DEFUALT; protected Liquid type = Liquid.DEFUALT;
public int capacity = 2; public int capacity = 2;
private int count = 0;
private int count2 = 0;
public int presure = 0; public int presure = 0;
public int connectedUnits = 0; public int connectedUnits = 0;
public int hPressure = 0; public int liquidStored = 0;
public int hPProducer = 0; private int count = 0;
protected int liquidStored = 0; private int count2 =0;
private boolean intiUpdate = true;
protected boolean firstUpdate = true; protected boolean firstUpdate = true;
public TileEntity[] connectedBlocks = {null, null, null, null, null, null}; public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
/**
* This function adds a connection between this pipe and other blocks
* @param tileEntity - Must be either a producer, consumer or a conductor
* @param side - side in which the connection is coming from
*/
public void addConnection(TileEntity tileEntity, ForgeDirection side)
{
this.connectedBlocks[side.ordinal()] = null;
if(tileEntity instanceof ILiquidConsumer)
{
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side))
{
this.connectedBlocks[side.ordinal()] = tileEntity;
}
}
if(tileEntity instanceof ILiquidProducer)
{
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
{
this.connectedBlocks[side.ordinal()] = tileEntity;
}
}
}
public int getPressure() public int getPressure()
{ {
return this.presure; return this.presure;
} }
/**
* onRecieveLiquid is called whenever a something sends a volume to the pipe (which is this block). @Override
* @param vols - The amount of vol source is trying to give to this pipe public void updateEntity()
* @param side - The side of the block in which the liquid came from {
* @return vol - The amount of rejected liquid that can't enter the pipe int highestPressure = 0;
*/ if(++count >= 5)
{
this.connectedBlocks = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
for(int i =0; i < 6; i++)
{
if(connectedBlocks[i] instanceof ILiquidConsumer && ((ILiquidConsumer) connectedBlocks[i]).canRecieveLiquid(this.type, ForgeDirection.getOrientation(i).getOpposite()))
{
this.connectedUnits++;
if(connectedBlocks[i] instanceof TileEntityPipe)
{
if(((TileEntityPipe) connectedBlocks[i]).getPressure() > highestPressure)
{
highestPressure = ((TileEntityPipe) connectedBlocks[i]).getPressure();
}
}
}
else
if(connectedBlocks[i] instanceof ILiquidProducer && ((ILiquidProducer) connectedBlocks[i]).canProduceLiquid(this.type, ForgeDirection.getOrientation(i).getOpposite()))
{
this.connectedUnits++;
if(((ILiquidProducer) connectedBlocks[i]).canProducePresure(this.type, ForgeDirection.getOrientation(i)) && ((ILiquidProducer) connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i).getOpposite()) > highestPressure)
{
highestPressure = ((ILiquidProducer) connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i));
}
}
else
{
connectedBlocks[i] = null;
}
}
if(!worldObj.isRemote)
{
if(firstUpdate || count2++ >= 10)
{ count2= 0;
firstUpdate = false;
Packet packet = PacketManager.getPacket("Pipes",this, new Object[]{this.type.ordinal()});
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 60);
}
this.presure = highestPressure -1;
for(int i =0; i < 6; i++)
{
if(connectedBlocks[i] instanceof ILiquidProducer)
{
int vol = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type, this.capacity - this.liquidStored, ForgeDirection.getOrientation(i).getOpposite());
this.liquidStored = Math.max(this.liquidStored + vol,this.capacity);
}
if(connectedBlocks[i] instanceof ILiquidConsumer && this.liquidStored > 0 && this.presure > 0)
{
if(connectedBlocks[i] instanceof TileEntityPipe)
{
this.liquidStored--;
int vol = ((ILiquidConsumer)connectedBlocks[i]).onReceiveLiquid(this.type, Math.max(this.liquidStored,1), ForgeDirection.getOrientation(i).getOpposite());
this.liquidStored += vol;
}else
{
this.liquidStored = ((ILiquidConsumer)connectedBlocks[i]).onReceiveLiquid(this.type, this.liquidStored, ForgeDirection.getOrientation(i).getOpposite());
}
}
}
}
}
}
//---------------
//liquid stuff
//---------------
@Override @Override
public int onReceiveLiquid(Liquid type,int vol, ForgeDirection side) public int onReceiveLiquid(Liquid type,int vol, ForgeDirection side)
{ {
@ -75,110 +117,6 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
} }
return vol; return vol;
} }
@Override
public void updateEntity()
{
if(++count >= 5)
{
this.connectedUnits = 0;
this.hPressure = 0;
this.hPProducer = 0;
count = 0;
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
if(!this.worldObj.isRemote)
{
if(firstUpdate || count2++ >= 10)
{ count2= 0;
firstUpdate = false;
Packet packet = PacketManager.getPacket("Pipes",this, new Object[]{this.type.ordinal()});
PacketManager.sendPacketToClients(packet, worldObj, Vector3.get(this), 60);
}
for(int i = 0; i < 6; i++)
{
if(connectedBlocks[i] instanceof ILiquidProducer)
{
if(((ILiquidProducer)connectedBlocks[i]).canProducePresure(this.type, ForgeDirection.getOrientation(i)))
{++this.connectedUnits;
if(((ILiquidProducer)connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i)) > hPProducer)
{
hPProducer = ((ILiquidProducer)connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i));
}
}
}
if(connectedBlocks[i] instanceof TileEntityPipe)
{
++this.connectedUnits;
if(((TileEntityPipe)connectedBlocks[i]).presure > hPressure)
{
hPressure = ((TileEntityPipe)connectedBlocks[i]).getPressure();
}
}
}//end of pressure update
this.presure = 0;
if(connectedUnits > 0)
{
if(hPProducer > 0)
{
this.presure = hPProducer;
}else
{
this.presure = Math.max(hPressure - 1,0);
}
}else
{
this.presure = 0;
}
//only trade liquid if there is more than one thing connect and its pressure is higher than 1
if(this.connectedUnits > 0 && this.presure > 0)
{
for(int i = 0; i < 6; i++)
{
if(connectedBlocks[i] != null)
{
//Spread the liquid among the different blocks
if(connectedBlocks[i] instanceof ILiquidConsumer && this.liquidStored > 0)
{
if(((ILiquidConsumer)connectedBlocks[i]).canRecieveLiquid(this.type,ForgeDirection.getOrientation(i)))
{
int transferVolumeAmount = 0; //amount to be moved
ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]);
if(connectedConsumer instanceof TileEntityPipe)
{
if(((TileEntityPipe)connectedBlocks[i]).presure < this.presure)
{
transferVolumeAmount = this.liquidStored;
}
}
else
{
transferVolumeAmount = this.liquidStored;
}
int rejectedVolume = connectedConsumer.onReceiveLiquid(this.type,transferVolumeAmount, ForgeDirection.getOrientation(i));
this.liquidStored = Math.max(Math.min(this.liquidStored - transferVolumeAmount + rejectedVolume, this.capacity), 0);
}
}
if(connectedBlocks[i] instanceof ILiquidProducer && this.liquidStored < this.getLiquidCapacity(type))
{
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,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));
}
}
}
}
}//end of liquid trader
}//end of !worldObj.isRemote
}
}
/** /**
* @return Return the stored volume in this pipe. * @return Return the stored volume in this pipe.
*/ */
@ -203,25 +141,6 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
return 0; return 0;
} }
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.liquidStored = par1NBTTagCompound.getInteger("liquid");
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("liquid", this.liquidStored);
par1NBTTagCompound.setInteger("type", this.type.ordinal());
}
//find wether or not this side of X block can recieve X liquid type. Also use to determine connection of a pipe //find wether or not this side of X block can recieve X liquid type. Also use to determine connection of a pipe
@Override @Override
public boolean canRecieveLiquid(Liquid type, ForgeDirection side) { public boolean canRecieveLiquid(Liquid type, ForgeDirection side) {
@ -243,7 +162,9 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
} }
//---------------------
//data
//--------------------
@Override @Override
public void handlePacketData(NetworkManager network, int packetType, public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player, Packet250CustomPayload packet, EntityPlayer player,
@ -263,13 +184,24 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
} }
/**
* Reads a tile entity from NBT.
*/
public int getSize() { public void readFromNBT(NBTTagCompound par1NBTTagCompound)
// TODO Auto-generated method stub {
return 6; super.readFromNBT(par1NBTTagCompound);
this.liquidStored = par1NBTTagCompound.getInteger("liquid");
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
} }
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("liquid", this.liquidStored);
par1NBTTagCompound.setInteger("type", this.type.ordinal());
}
} }

View file

@ -34,10 +34,10 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements ILi
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
if(count++ >= 20) if(count++ >= 40)
{ {
count = 0; count = 0;
sList = MHelper.getSourounding(this); sList = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord); int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
Liquid bellow = Liquid.getLiquidByBlock(bBlock); Liquid bellow = Liquid.getLiquidByBlock(bBlock);

View file

@ -55,7 +55,7 @@ boolean on = false;
case 4: deltaX++;break; case 4: deltaX++;break;
} }
connected = MHelper.getSourounding(this); connected = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
for(int i = 0;i<6;i++) for(int i = 0;i<6;i++)
{ {
if(!(connected[i] instanceof TileEntityPipe)) if(!(connected[i] instanceof TileEntityPipe))

View file

@ -1,5 +1,7 @@
package basicpipes.pipes.api; package basicpipes.pipes.api;
import net.minecraftforge.common.ForgeDirection;
public interface IHeatProducer public interface IHeatProducer
{ {
@ -7,8 +9,8 @@ public interface IHeatProducer
* onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer * onProduceElectricity is called when a conductor is connected to the producer block in which the conductor will demand power from the producer
* block. * block.
* @param jouls - The maximum jouls can be transfered * @param jouls - The maximum jouls can be transfered
* @param side - The side of block in which the conductor is on * @param up - The side of block in which the conductor is on
* @return jouls - Return jouls to consumer * @return jouls - Return jouls to consumer
*/ */
public float onProduceHeat(float jouls, int side); public float onProduceHeat(float jouls, ForgeDirection up);
} }

View file

@ -0,0 +1,5 @@
package basicpipes.pipes.api;
public interface IStorageTank extends ILiquidConsumer {
}

View file

@ -1,21 +1,23 @@
package basicpipes.pipes.api; package basicpipes.pipes.api;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
public class MHelper { public class MHelper {
/** /**
* * you will have to tell your TileEntity to trade up if liquid or down if gas. I suggest having your onRecieveLiquid
* pump liquid one block up if you block is full.
* @param entity - entity at center of search * @param entity - entity at center of search
* @return an Array containing TileEntities around the TileEntity * @return an Array containing TileEntities around the TileEntity
*/ */
public static TileEntity[] getSourounding(TileEntity te) public static TileEntity[] getSourounding(World world, int x, int y, int z)
{ {
TileEntity[] list = new TileEntity[]{null,null,null,null,null,null}; TileEntity[] list = new TileEntity[]{null,null,null,null,null,null};
for(int i =0; i< 6;i++) for(int i =0; i< 6;i++)
{ {
ForgeDirection d = ForgeDirection.getOrientation(i); ForgeDirection d = ForgeDirection.getOrientation(i);
TileEntity aEntity = te.worldObj.getBlockTileEntity(te.xCoord+d.offsetX, te.yCoord+d.offsetY, te.zCoord+d.offsetZ); TileEntity aEntity = world.getBlockTileEntity(x+d.offsetX, y+d.offsetY, z+d.offsetZ);
if(aEntity instanceof TileEntity) if(aEntity instanceof TileEntity)
{ {
list[i] = aEntity; list[i] = aEntity;
@ -30,37 +32,64 @@ public class MHelper {
* @param vol - the volume to be traded * @param vol - the volume to be traded
* @return the remaining untraded liquid * @return the remaining untraded liquid
*/ */
public static int shareLiquid(TileEntity te, Liquid type,int vol) public static int shareLiquid(World world, int x, int y, int z,int vol,int max, Liquid type)
{ {
TileEntity ent = world.getBlockTileEntity(x, y, z);
int currentVol = vol; int currentVol = vol;
int tCount = 1;
boolean rise = type.isGas; boolean rise = type.isGas;
ForgeDirection st = ForgeDirection.getOrientation(rise ? 1 : 0); if(currentVol <= 0)
TileEntity first = te.worldObj.getBlockTileEntity(te.xCoord+st.offsetX, te.yCoord+st.offsetX, te.zCoord+st.offsetX);
//trades to the first, bottom for liquid, top for gas
if(first instanceof ILiquidConsumer && ((ILiquidConsumer) first).getStoredLiquid(type) < ((ILiquidConsumer) first).getLiquidCapacity(type))
{ {
currentVol = ((ILiquidConsumer) first).onReceiveLiquid(type, vol, st); return 0;
} }
ForgeDirection st = ForgeDirection.getOrientation(rise ? 1 : 0);
TileEntity first = world.getBlockTileEntity(x+st.offsetX, y+st.offsetY, z+st.offsetZ);
//trades to the first, bottom for liquid, top for gas
if(first instanceof IStorageTank && currentVol > 0 && ((IStorageTank) first).getStoredLiquid(type) < ((IStorageTank) first).getLiquidCapacity(type))
{
currentVol = ((ILiquidConsumer) first).onReceiveLiquid(type, currentVol, st);
}
int vAve = currentVol;
TileEntity[] TeA = MHelper.getSourounding(world,x,y,z);
for(int i = 2; i < 6; i++)
{
if(TeA[i] instanceof IStorageTank)
{
vAve += ((IStorageTank)TeA[i]).getStoredLiquid(type);
tCount++;
}
}
vAve = (int)(vAve/tCount);
//trades to side if anything is left //trades to side if anything is left
for(int i = 2; i < 6;i++) for(int i = 2; i < 6;i++)
{ {
ForgeDirection side = ForgeDirection.getOrientation(i); ForgeDirection side = ForgeDirection.getOrientation(i);
TileEntity sSide = te.worldObj.getBlockTileEntity(te.xCoord+side.offsetX, te.yCoord+side.offsetX, te.zCoord+side.offsetX); TileEntity sSide = world.getBlockTileEntity(x+side.offsetX, y+side.offsetY, z+side.offsetZ);
if(sSide instanceof ILiquidConsumer && ((ILiquidConsumer) sSide).getStoredLiquid(type) < ((ILiquidConsumer) sSide).getLiquidCapacity(type) if(currentVol <= 0 || currentVol <= vAve)
&& currentVol > 0)
{ {
currentVol = ((ILiquidConsumer) sSide).onReceiveLiquid(type, vol, st); break;
}
if(sSide instanceof IStorageTank &&((IStorageTank) sSide).getStoredLiquid(type) < vAve)
{
int tA = vAve -Math.max((vAve - currentVol), 0);
currentVol = ((ILiquidConsumer) sSide).onReceiveLiquid(type, tA, st) -tA + currentVol;
} }
} }
//trades to the opposite of the first if anything is left //trades to the opposite of the first if anything is left
/**
* need to find a way to solve it just trading back the ammount on next cycle
if(currentVol > 0) if(currentVol > 0)
{ {
TileEntity last = te.worldObj.getBlockTileEntity(te.xCoord+st.getOpposite().offsetX, te.yCoord+st.getOpposite().offsetX, te.zCoord+st.getOpposite().offsetX); TileEntity last = world.getBlockTileEntity(x+st.getOpposite().offsetX, y+st.getOpposite().offsetY, z+st.getOpposite().offsetZ);
if(last instanceof ILiquidConsumer && ((ILiquidConsumer) last).getStoredLiquid(type) < ((ILiquidConsumer) last).getLiquidCapacity(type)) if(last instanceof IStorageTank && currentVol == max)
{ {
currentVol = ((ILiquidConsumer) last).onReceiveLiquid(type, vol, st); currentVol = ((ILiquidConsumer) last).onReceiveLiquid(type, max/10, st.getOpposite()) + currentVol -(max/10);
} }
} }
*/
return Math.max(currentVol,0); return Math.max(currentVol,0);
} }
/** /**
@ -72,7 +101,7 @@ public class MHelper {
*/ */
public static int corner(TileEntity entity) public static int corner(TileEntity entity)
{ {
TileEntity[] en = getSourounding(entity); TileEntity[] en = getSourounding(entity.worldObj, entity.xCoord,entity.yCoord,entity.zCoord);
if(en[4] != null && en[2] != null && en[5] == null && en[3] == null) if(en[4] != null && en[2] != null && en[5] == null && en[3] == null)
{ {
return 3; return 3;

View file

@ -1,16 +1,18 @@
package steampower.turbine; package steampower;
import net.minecraft.src.Container; import net.minecraft.src.Container;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.InventoryPlayer; import net.minecraft.src.InventoryPlayer;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.Slot; import net.minecraft.src.Slot;
import net.minecraft.src.TileEntity;
public class ContainerGenerator extends Container public class ContainerFake extends Container
{ {
private TileEntitySteamPiston tileEntity; private IInventory tileEntity;
public ContainerGenerator(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity) public ContainerFake(InventoryPlayer par1InventoryPlayer, IInventory tileEntity)
{ {
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
// this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34)); // this.addSlotToContainer(new Slot(tileEntity, 0, 33, 34));

View file

@ -24,7 +24,7 @@ import cpw.mods.fml.common.network.NetworkMod;
import cpw.mods.fml.common.network.NetworkRegistry; import cpw.mods.fml.common.network.NetworkRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry; import cpw.mods.fml.common.registry.LanguageRegistry;
@Mod(modid = "SteamPower", name = "Steam Power", version = "1.7",dependencies = "after:basicPipes") @Mod(modid = "SteamPower", name = "Steam Power", version = "1.9",dependencies = "after:basicPipes")
@NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class) @NetworkMod(channels = { "SPpack" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
public class SteamPowerMain{ public class SteamPowerMain{

View file

@ -1,13 +1,12 @@
package steampower; package steampower;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.IInventory;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraft.src.World; import net.minecraft.src.World;
import steampower.boiler.ContainerBoiler;
import steampower.boiler.TileEntityBoiler; import steampower.boiler.TileEntityBoiler;
import steampower.burner.ContainerFireBox; import steampower.burner.ContainerFireBox;
import steampower.burner.TileEntityFireBox; import steampower.burner.TileEntityFireBox;
import steampower.turbine.ContainerGenerator;
import steampower.turbine.TileEntityGen; import steampower.turbine.TileEntityGen;
import steampower.turbine.TileEntitySteamPiston; import steampower.turbine.TileEntitySteamPiston;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;
@ -59,8 +58,7 @@ public class SteamProxy implements IGuiHandler{
switch(ID) switch(ID)
{ {
case 0: return new ContainerFireBox(player.inventory, ((TileEntityFireBox)tileEntity)); case 0: return new ContainerFireBox(player.inventory, ((TileEntityFireBox)tileEntity));
case 1: return new ContainerBoiler(player.inventory, ((TileEntityBoiler)tileEntity)); default: return new ContainerFake(player.inventory, (IInventory) tileEntity);
case 2: return new ContainerGenerator(player.inventory, ((TileEntitySteamPiston)tileEntity));
} }
} }

View file

@ -84,8 +84,9 @@ public class TileEntityMachine extends TileEntity implements IInventory, ISided
} }
public boolean needUpdate() public boolean needUpdate()
{ {
return false; return true;
} }
@Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();

View file

@ -1,58 +0,0 @@
package steampower.boiler;
import net.minecraft.src.*;
public class ContainerBoiler extends Container
{
private TileEntityBoiler boiler;
private int lastCookTime = 0;
private int lastBurnTime = 0;
private int lastItemBurnTime = 0;
public ContainerBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityboiler)
{
this.boiler = par2TileEntityboiler;
this.addSlotToContainer(new Slot(par2TileEntityboiler, 0, 56, 17));
int line;
for (line = 0; line < 3; ++line)
{
for (int slot = 0; slot < 9; ++slot)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, slot + line * 9 + 9, 8 + slot * 18, 84 + line * 18));
}
}
for (line = 0; line < 9; ++line)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, line, 8 + line * 18, 142));
}
}
public void updateProgressBar(int par1, int par2)
{
if (par1 == 0)
{
// this.boiler.furnaceCookTime = par2;
}
if (par1 == 1)
{
//this.boiler.boilerRunTime = par2;
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.boiler.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called to transfer a stack from one inventory to the other eg. when shift clicking.
*/
public ItemStack transferStackInSlot(int par1)
{
return null;
}
}

View file

@ -6,6 +6,7 @@ import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item; import net.minecraft.src.Item;
import net.minecraft.src.ItemStack; import net.minecraft.src.ItemStack;
import net.minecraft.src.NBTTagCompound; import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NBTTagList;
import net.minecraft.src.NetworkManager; import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
@ -13,256 +14,126 @@ import net.minecraftforge.common.ForgeDirection;
import steampower.SteamPowerMain; import steampower.SteamPowerMain;
import steampower.TileEntityMachine; import steampower.TileEntityMachine;
import universalelectricity.network.IPacketReceiver; import universalelectricity.network.IPacketReceiver;
import basicpipes.conductors.TileEntityPipe;
import basicpipes.pipes.api.IHeatProducer; 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.IStorageTank;
import basicpipes.pipes.api.Liquid; import basicpipes.pipes.api.Liquid;
import basicpipes.pipes.api.MHelper; import basicpipes.pipes.api.MHelper;
import com.google.common.io.ByteArrayDataInput; import com.google.common.io.ByteArrayDataInput;
public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiver,ILiquidProducer, ILiquidConsumer public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiver,ILiquidProducer, IStorageTank
{ {
public int steam = 0;
/** public int water = 0;
* The ItemStacks that hold the items currently being used in the furnace public int heat = 0;
*/
/** The number of ticks that the boiler will keep burning */
public int RunTime = 0;
/** The ammount of water stored */
public int waterStored = 0;
/** The ammount of steam stored */
public int steamStored = 0;
/** The ammount of heat stored */
public int heatStored = 0;
public int heatMax = 10000;
/** The ammount of heat stored */
public int hullHeat = 0; public int hullHeat = 0;
public int hullHeatMax = 4700;
private int heatTick = 0;
public int tankCount = 0;
private int heatNeeded = SteamPowerMain.boilerHeat; // kilo joules
int count = 0;
boolean hullHeated = false;
public TileEntity[] connectedBlocks = {null,null,null,null,null,null}; public TileEntity[] connectedBlocks = {null,null,null,null,null,null};
int steamMax = 140; public int tankCount = 0;
public boolean isBeingHeated = false; public int tickCount = 0;
private Random random = new Random();
private int pWater = 0;
private int pSteam = 0;
private int pHullH = 0;
public String getInvName()
{
return "container.boiler";
}
public Object[] getSendData()
{
return new Object[]{(int)RunTime,(int)waterStored,
(int)steamStored,(int)heatStored,(int)hullHeat,(int)heatTick};
}
@Override //-----------------------------
public void handlePacketData(NetworkManager network, int packetType, //Update stuff
Packet250CustomPayload packet, EntityPlayer player, //-----------------------------
ByteArrayDataInput dataStream) {
try
{
RunTime = dataStream.readInt();
waterStored = dataStream.readInt();
steamStored = dataStream.readInt();
heatStored = dataStream.readInt();
hullHeat = dataStream.readInt();
heatTick = dataStream.readInt();
}
catch(Exception e)
{
e.printStackTrace();
}
}
/**
* Reads a tile entity from NBT.
*/
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.RunTime = par1NBTTagCompound.getShort("BurnTime");
this.steamStored = par1NBTTagCompound.getInteger("steamStore");
this.heatStored = par1NBTTagCompound.getInteger("heatStore");
this.waterStored = par1NBTTagCompound.getInteger("waterStore");
this.hullHeat = par1NBTTagCompound.getInteger("hullHeat");
}
/**
* Writes a tile entity to NBT.
*/
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setShort("BurnTime", (short)this.RunTime);
par1NBTTagCompound.setInteger("steamStore", (int)this.steamStored);
par1NBTTagCompound.setInteger("heatStore", (int)this.heatStored);
par1NBTTagCompound.setInteger("waterStore", (int)this.waterStored);
par1NBTTagCompound.setInteger("hullHeat", (int)this.hullHeat);
}
/**
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
* ticks and creates a new spawn inside its implementation.
*/
public boolean needUpdate()
{
if(this.pWater != this.waterStored || this.pSteam != this.steamStored || this.pHullH != this.hullHeat)
{
return true;
}
return false;
}
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); //update connection list used for rendering
if(count++ >=20) this.connectedBlocks = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
this.tankCount = 0;
for(int i =0; i < connectedBlocks.length; i++)
{ {
count = 0; if(connectedBlocks[i] != null)
//update/resets connection list
TileEntity[] entityList = MHelper.getSourounding(this);
tankCount = 0;
for(int c = 0; c< 6; c++)
{
if(entityList[c] instanceof TileEntityBoiler)
{
connectedBlocks[c] = entityList[c];
if(c != 0 && c != 1)
{ {
tankCount++; tankCount++;
} }
} }//end connection update
else if(tickCount++ >= 10 && !worldObj.isRemote)
{ {
connectedBlocks[c] = null; tickCount = 0;
}
}
hullHeated = false; TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord-1, zCoord);
if(hullHeat >= hullHeatMax) if(ent instanceof IHeatProducer)
{ {
hullHeated = true; this.heat = (int) Math.min(((IHeatProducer)ent).onProduceHeat(250, ForgeDirection.UP)+heat,2000);
} }else
else if(worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.lavaStill.blockID)
{ {
if(!worldObj.isRemote) this.heat = Math.min(90+heat,2000);
}
if(hullHeat < 10000)
{ {
hullHeat = Math.min(hullHeat + heatStored, hullHeatMax); int mHeat = 10000 - hullHeat;
} int hHeat = mHeat - Math.max((mHeat - this.heat),0);
} hullHeat = Math.min(hullHeat + hHeat,10000);
this.heat -=hHeat;
if(!worldObj.isRemote) }else
{ {
if(heat >= 2000 && this.water >= 1 && this.steam < this.getLiquidCapacity(Liquid.STEAM))
emptyBuckets();
//adds water from container slot
this.waterStored = MHelper.shareLiquid(this, Liquid.WATER, this.waterStored);
this.steamStored = MHelper.shareLiquid(this, Liquid.STEAM, this.steamStored);
if(waterStored > 0 && hullHeated && heatStored > heatNeeded)
{ {
heatStored = Math.max(heatStored - heatNeeded, 0); this.water--;
--waterStored; this.steam = Math.min(this.steam +20,this.getLiquidCapacity(Liquid.STEAM));
steamStored = Math.min(steamStored + 20,this.steamMax); this.heat -= 2000;
} }
this.hullHeat-=5;
TileEntity blockE = worldObj.getBlockTileEntity(xCoord, yCoord -1, zCoord);
this.isBeingHeated = false;
if(blockE instanceof IHeatProducer)
{
this.isBeingHeated = true;
heatStored = (int) Math.min((heatStored + ((IHeatProducer)blockE).onProduceHeat(250, 1)), heatMax);
} }
else if(worldObj.getBlockId(xCoord, yCoord-1, zCoord) == Block.lavaStill.blockID) this.water = MHelper.shareLiquid(worldObj,xCoord, yCoord, zCoord,this.water,this.getLiquidCapacity(Liquid.WATER), Liquid.WATER);
{ this.steam = MHelper.shareLiquid(worldObj,xCoord, yCoord, zCoord,this.steam,this.getLiquidCapacity(Liquid.STEAM), Liquid.STEAM);
heatStored += (int) Math.min((int)(random.nextDouble()*100), heatMax);
} }
//keeps track of what the previous measure were so packets stop sending after the machine doesn't change any super.updateEntity();
this.pWater = this.waterStored;
this.pSteam = this.steamStored;
this.pHullH = this.hullHeat;
}
}
}
private void emptyBuckets()
{
if (storedItems[0] != null)
{
if(storedItems[0].isItemEqual(new ItemStack(Item.bucketWater,1)))
{
if((int)waterStored < getLiquidCapacity(Liquid.WATER))
{
++waterStored;
this.storedItems[0] = new ItemStack(Item.bucketEmpty,1);
this.onInventoryChanged();
}
}
if(storedItems[0].isItemEqual(new ItemStack(Block.ice,1)))
{
if((int)waterStored < getLiquidCapacity(Liquid.WATER) && this.heatStored > 100)
{
++waterStored;
int stacksize = this.storedItems[0].stackSize;
if(stacksize > 1)
{
this.storedItems[0] = new ItemStack(Block.ice,stacksize -1);
}
if(stacksize == 1)
{
this.storedItems[0] = null;
}
this.heatStored-=100;
this.onInventoryChanged();
}
}
}
}
public int precentHeated() {
int var1 = 0;
if(hullHeat < 100)
{
var1 = (int)(100 *(hullHeat/hullHeatMax));
}
else
{
var1 = 100;
}
return var1;
} }
//-----------------------------
//Liquid stuff
//-----------------------------
@Override @Override
public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side) { public int onReceiveLiquid(Liquid type, int vol, ForgeDirection side)
if(type == Liquid.STEAM)
{ {
int rejectedSteam = Math.max((this.steamStored + vol) - this.getLiquidCapacity(Liquid.STEAM), 0);
this.steamStored += vol - rejectedSteam;
return rejectedSteam;
}
if(type == Liquid.WATER) if(type == Liquid.WATER)
{ {
int rejectedWater = Math.max((this.waterStored + vol) - this.getLiquidCapacity(Liquid.WATER), 0); if(this.water < this.getLiquidCapacity(Liquid.WATER))
this.waterStored += vol - rejectedWater; {
return rejectedWater; int rej = Math.max((this.water + vol) - this.getLiquidCapacity(Liquid.WATER), 0);
this.water += vol - rej;
return rej;
}
else
{
TileEntity te = worldObj.getBlockTileEntity(xCoord, yCoord+1, zCoord);
if( te instanceof IStorageTank)
{
return ((IStorageTank)te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN);
}
}
}else
if(type == Liquid.STEAM)
{
if(this.steam < this.getLiquidCapacity(Liquid.STEAM))
{
int rej = Math.max((this.steam + vol) - this.getLiquidCapacity(Liquid.STEAM), 0);
this.steam += vol - rej;
return rej;
}
else
{
TileEntity te = worldObj.getBlockTileEntity(xCoord, yCoord-1, zCoord);
if( te instanceof IStorageTank)
{
return ((IStorageTank)te).onReceiveLiquid(type, vol, ForgeDirection.UNKNOWN);
}
}
} }
return vol; return vol;
} }
@Override @Override
public boolean canRecieveLiquid(Liquid type,ForgeDirection side) { public boolean canRecieveLiquid(Liquid type, ForgeDirection s) {
if(type == Liquid.WATER) if(type == Liquid.WATER)
{
return true;
}else
if(type == Liquid.STEAM && s == ForgeDirection.UNKNOWN)
{ {
return true; return true;
} }
@ -273,11 +144,11 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
public int getStoredLiquid(Liquid type) { public int getStoredLiquid(Liquid type) {
if(type == Liquid.WATER) if(type == Liquid.WATER)
{ {
return this.waterStored; return this.water;
} }else
if(type == Liquid.STEAM) if(type == Liquid.STEAM)
{ {
return this.steamStored; return this.steam;
} }
return 0; return 0;
} }
@ -287,20 +158,27 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
if(type == Liquid.WATER) if(type == Liquid.WATER)
{ {
return 14; return 14;
} }else
if(type == Liquid.STEAM) if(type == Liquid.STEAM)
{ {
return steamMax; return 140;
} }
return 0; return 0;
} }
@Override @Override
public int onProduceLiquid(Liquid type, int maxVol, ForgeDirection side) { public int onProduceLiquid(Liquid type, int vol, ForgeDirection side) {
if(type == Liquid.STEAM) if(type == Liquid.STEAM)
{ {
if(steamStored > 1) //TODO setup the actual math for this
if(vol < this.steam)
{ {
this.steamStored -= 1; this.steam -= vol;
return vol;
}else
if(this.steam >= 1)
{
this.steam -= 1;
return 1; return 1;
} }
} }
@ -315,21 +193,65 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
} }
return false; return false;
} }
@Override @Override
public int presureOutput(Liquid type, ForgeDirection side) { public boolean canProducePresure(Liquid type, ForgeDirection side) {
if(type == Liquid.STEAM)
{
return (this.steamStored/this.steamMax)*40 +60;
}
return 0;
}
@Override
public boolean canProducePresure(Liquid type, ForgeDirection side)
{
if(type == Liquid.STEAM) if(type == Liquid.STEAM)
{ {
return true; return true;
} }
return false; return false;
} }
@Override
public int presureOutput(Liquid type, ForgeDirection side) {
if(type == Liquid.STEAM)
{
return 100;
}
return 0;
}
//-----------------------------
//Data
//-----------------------------
public Object[] getSendData()
{
return new Object[]{this.water,this.steam,this.heat,this.hullHeat};
}
@Override
public void handlePacketData(NetworkManager network, int packetType,
Packet250CustomPayload packet, EntityPlayer player,
ByteArrayDataInput dataStream) {
try{
this.water = dataStream.readInt();
this.steam = dataStream.readInt();
this.heat = dataStream.readInt();
this.hullHeat = dataStream.readInt();
}catch(Exception e)
{
e.printStackTrace();
}
}
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
par1NBTTagCompound.setInteger("water", this.water);
par1NBTTagCompound.setInteger("steam", this.steam);
par1NBTTagCompound.setInteger("heat", this.heat);
par1NBTTagCompound.setInteger("hullHeat", this.hullHeat);
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.water = par1NBTTagCompound.getInteger("water");
this.steam = par1NBTTagCompound.getInteger("steam");
this.heat = par1NBTTagCompound.getInteger("heat");
this.hullHeat = par1NBTTagCompound.getInteger("hullHeat");
}
} }

View file

@ -8,6 +8,7 @@ import net.minecraft.src.NBTTagCompound;
import net.minecraft.src.NetworkManager; import net.minecraft.src.NetworkManager;
import net.minecraft.src.Packet250CustomPayload; import net.minecraft.src.Packet250CustomPayload;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.ISidedInventory; import net.minecraftforge.common.ISidedInventory;
import steampower.SteamPowerMain; import steampower.SteamPowerMain;
import steampower.TileEntityMachine; import steampower.TileEntityMachine;
@ -87,7 +88,7 @@ public class TileEntityFireBox extends TileEntityMachine implements IPacketRecei
this.itemCookTime --; this.itemCookTime --;
if(isConnected) if(isConnected)
{ {
this.generateRate = Math.min(this.generateRate+Math.min((this.generateRate)+1, 1), this.maxGenerateRate/20); this.generateRate = Math.min(this.generateRate+Math.min((this.generateRate)+1, 1), this.maxGenerateRate/10);
} }
} }
//Loose heat when the generator is not connected or if there is no coal in the inventory. //Loose heat when the generator is not connected or if there is no coal in the inventory.
@ -142,7 +143,7 @@ public class TileEntityFireBox extends TileEntityMachine implements IPacketRecei
public void addConnection() public void addConnection()
{ {
connectedUnits = 0; connectedUnits = 0;
TileEntity[] aEntity = MHelper.getSourounding(this); TileEntity[] aEntity = MHelper.getSourounding(worldObj,xCoord, yCoord, zCoord);
for(int i = 0; i<6; i++) for(int i = 0; i<6; i++)
{ {
@ -180,9 +181,12 @@ public class TileEntityFireBox extends TileEntityMachine implements IPacketRecei
public String getInvName() { public String getInvName() {
return "FireBox"; return "FireBox";
} }
public float onProduceHeat(float jouls, int side) { public float onProduceHeat(float jouls, ForgeDirection side) {
// TODO Auto-generated method stub if(side == ForgeDirection.UP)
return Math.min(generateRate*getTickInterval(),jouls); {
return Math.min(generateRate,jouls);
}
return 0;
} }
@Override @Override
public Object[] getSendData() public Object[] getSendData()

View file

@ -30,14 +30,11 @@ public class RenderPipe extends TileEntitySpecialRenderer
//Texture file //Texture file
type = tileEntity.getType(); type = tileEntity.getType();
size = tileEntity.getSize();
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
if(size == 6)
{
switch(type.ordinal()) switch(type.ordinal())
{ {
case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break; case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break;
@ -53,7 +50,6 @@ public class RenderPipe extends TileEntitySpecialRenderer
if(tileEntity.connectedBlocks[5] != null) SixPipe.renderRight(); if(tileEntity.connectedBlocks[5] != null) SixPipe.renderRight();
if(tileEntity.connectedBlocks[4] != null) SixPipe.renderLeft(); if(tileEntity.connectedBlocks[4] != null) SixPipe.renderLeft();
SixPipe.renderMiddle(); SixPipe.renderMiddle();
}
GL11.glPopMatrix(); GL11.glPopMatrix();
} }

View file

@ -6,7 +6,6 @@ import net.minecraft.src.StatCollector;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import steampower.turbine.ContainerGenerator;
import steampower.turbine.TileEntitySteamPiston; import steampower.turbine.TileEntitySteamPiston;
import universalelectricity.electricity.ElectricInfo; import universalelectricity.electricity.ElectricInfo;
import universalelectricity.electricity.ElectricInfo.ElectricUnit; import universalelectricity.electricity.ElectricInfo.ElectricUnit;
@ -20,7 +19,7 @@ import universalelectricity.electricity.ElectricInfo.ElectricUnit;
public GUISteamPiston(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity) public GUISteamPiston(InventoryPlayer par1InventoryPlayer, TileEntitySteamPiston tileEntity)
{ {
super(new ContainerGenerator(par1InventoryPlayer, tileEntity)); super(new ContainerFake(par1InventoryPlayer, tileEntity));
this.tileEntity = tileEntity; this.tileEntity = tileEntity;
} }

View file

@ -7,10 +7,8 @@ import net.minecraft.src.StatCollector;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import basicpipes.pipes.api.Liquid;
import steampower.boiler.ContainerBoiler;
import steampower.boiler.TileEntityBoiler; import steampower.boiler.TileEntityBoiler;
import basicpipes.pipes.api.Liquid;
public class GuiBoiler extends GuiContainer public class GuiBoiler extends GuiContainer
{ {
@ -18,7 +16,7 @@ public class GuiBoiler extends GuiContainer
public GuiBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityGrinder) public GuiBoiler(InventoryPlayer par1InventoryPlayer, TileEntityBoiler par2TileEntityGrinder)
{ {
super(new ContainerBoiler(par1InventoryPlayer, par2TileEntityGrinder)); super(new ContainerFake(par1InventoryPlayer, par2TileEntityGrinder));
this.boilerInventory = par2TileEntityGrinder; this.boilerInventory = par2TileEntityGrinder;
} }
@ -51,23 +49,27 @@ public class GuiBoiler extends GuiContainer
int var8; int var8;
int var9; int var9;
int var10; int var10;
if (this.boilerInventory.waterStored > 0) if (this.boilerInventory.getStoredLiquid(Liquid.WATER)> 0)
{ {
var7 = boilerInventory.getStoredLiquid(Liquid.WATER)*4 + 1; var7 = boilerInventory.getStoredLiquid(Liquid.WATER)*4 + 1;
this.drawTexturedModalRect(var5 + 29, var6 + 72 - var7, 176, 148 - var7, 23, var7); this.drawTexturedModalRect(var5 + 29, var6 + 72 - var7, 176, 148 - var7, 23, var7);
} }
if (this.boilerInventory.steamStored > 0) if (this.boilerInventory.getStoredLiquid(Liquid.STEAM) > 0)
{ {
var8 = boilerInventory.steamStored/14*4 + 1; var8 = boilerInventory.getStoredLiquid(Liquid.STEAM)/14*4 + 1;
this.drawTexturedModalRect(var5 + 108, var6 + 72 - var8, 176, 90 - var8, 23, var8); this.drawTexturedModalRect(var5 + 108, var6 + 72 - var8, 176, 90 - var8, 23, var8);
} }
float precentH = Math.min(boilerInventory.hullHeat/1000 + 1, 10); float precentH = Math.min(boilerInventory.hullHeat/1000 + 1, 10);
var9 = (int) Math.min(precentH*3.0F,30); var9 = (int) Math.min(precentH*3.0F,30);
this.drawTexturedModalRect(var5 + 59, var6 + 70 - var9, 199, 71 - var9, 9, var9); this.drawTexturedModalRect(var5 + 59, var6 + 70 - var9, 199, 71 - var9, 9, var9);
float precentSH = this.boilerInventory.heatStored/1000; float precentSH = this.boilerInventory.heat/1000;
var10 = (int) Math.round(precentSH*5.33); var10 = (int) Math.round(precentSH*5.33);
this.drawTexturedModalRect(var5 + 78, var6 + 16, 176, 14, var10, 16); this.drawTexturedModalRect(var5 + 78, var6 + 16, 176, 14, var10, 16);
//debug
this.fontRenderer.drawString("NonGraphic Debug", (int)(200), 90, 000000);
this.fontRenderer.drawString("Water:"+this.boilerInventory.water+"/14", (int)(200), 100, 000000);
this.fontRenderer.drawString("Steam:"+this.boilerInventory.steam+"/140", (int)(200), 110, 000000);
} }
public static String getWattDisplay(int watts) public static String getWattDisplay(int watts)