add presure to pipes
mainly use only for max range of a pipe but later i'll add leaking and breaking of pipes
This commit is contained in:
parent
cce1196292
commit
88ee4ca306
19 changed files with 420 additions and 110 deletions
|
@ -1 +1 @@
|
||||||
3
|
4
|
|
@ -1 +1 @@
|
||||||
6
|
7
|
84
src/common/aa/BlockDev.java
Normal file
84
src/common/aa/BlockDev.java
Normal file
|
@ -0,0 +1,84 @@
|
||||||
|
package aa;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import net.minecraft.src.Block;
|
||||||
|
import net.minecraft.src.BlockContainer;
|
||||||
|
import net.minecraft.src.CreativeTabs;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraft.src.Material;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
|
||||||
|
public class BlockDev extends BlockContainer {
|
||||||
|
|
||||||
|
public BlockDev(int par1) {
|
||||||
|
super(par1, Material.rock);
|
||||||
|
this.setBlockName("Machine");
|
||||||
|
this.setCreativeTab(CreativeTabs.tabBlock);
|
||||||
|
//this.setRequiresSelfNotify();
|
||||||
|
// this.blockIndexInTexture = 26;
|
||||||
|
}
|
||||||
|
public boolean isOpaqueCube()
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean renderAsNormalBlock()
|
||||||
|
{
|
||||||
|
//TODO change later when custom models are added
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
public int getBlockTextureFromSideAndMetadata(int side, int meta)
|
||||||
|
{
|
||||||
|
if(meta == 0)
|
||||||
|
{
|
||||||
|
if(side == 0 || side == 1)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* The type of render function that is called for this block
|
||||||
|
*/
|
||||||
|
public int getRenderType()
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the ID of the items to drop on destruction.
|
||||||
|
*/
|
||||||
|
public int idDropped(int par1, Random par2Random, int par3)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
public void addCreativeItems(ArrayList itemList)
|
||||||
|
{
|
||||||
|
|
||||||
|
itemList.add(new ItemStack(this, 1,0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World var1,int meta) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
if(meta == 0)
|
||||||
|
{
|
||||||
|
return new TileEntityAntiMob();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World var1) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public String getTextureFile() {
|
||||||
|
return "/textures/DevBlocks.png";}
|
||||||
|
|
||||||
|
}
|
54
src/common/aa/DevMain.java
Normal file
54
src/common/aa/DevMain.java
Normal file
|
@ -0,0 +1,54 @@
|
||||||
|
package aa;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
|
||||||
|
import net.minecraft.src.Block;
|
||||||
|
import net.minecraft.src.Item;
|
||||||
|
import net.minecraft.src.ItemStack;
|
||||||
|
import net.minecraftforge.common.Configuration;
|
||||||
|
import cpw.mods.fml.common.Mod;
|
||||||
|
import cpw.mods.fml.common.SidedProxy;
|
||||||
|
import cpw.mods.fml.common.Mod.Init;
|
||||||
|
import cpw.mods.fml.common.Mod.PostInit;
|
||||||
|
import cpw.mods.fml.common.Mod.PreInit;
|
||||||
|
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||||
|
import cpw.mods.fml.common.network.NetworkMod;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||||
|
|
||||||
|
@Mod(modid = "DevBox", name = "Dev Box", version = "Unknown")
|
||||||
|
@NetworkMod(channels = { "DevD" }, clientSideRequired = true, serverSideRequired = false)
|
||||||
|
|
||||||
|
public class DevMain{
|
||||||
|
|
||||||
|
public DevMain instance;
|
||||||
|
@SidedProxy(clientSide = "aa.DevProxy", serverSide = "aa.DevProxy")
|
||||||
|
public static DevProxy proxy;
|
||||||
|
Block devBlock = new BlockDev(3533);
|
||||||
|
|
||||||
|
@PreInit
|
||||||
|
public void preInit(FMLPreInitializationEvent event)
|
||||||
|
{
|
||||||
|
proxy.preInit();
|
||||||
|
GameRegistry.registerBlock(devBlock);
|
||||||
|
}
|
||||||
|
@Init
|
||||||
|
public void load(FMLInitializationEvent evt)
|
||||||
|
{
|
||||||
|
//register
|
||||||
|
proxy.init();
|
||||||
|
GameRegistry.registerTileEntity(TileEntityAntiMob.class, "DevAntiMob");
|
||||||
|
//Names and lang stuff
|
||||||
|
|
||||||
|
}
|
||||||
|
@PostInit
|
||||||
|
public void postInit(FMLPostInitializationEvent event)
|
||||||
|
{
|
||||||
|
proxy.postInit();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
63
src/common/aa/DevProxy.java
Normal file
63
src/common/aa/DevProxy.java
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
package aa;
|
||||||
|
|
||||||
|
import net.minecraft.src.EntityPlayer;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
import net.minecraft.src.World;
|
||||||
|
import net.minecraftforge.client.MinecraftForgeClient;
|
||||||
|
import basicpipes.BasicPipesMain;
|
||||||
|
import basicpipes.pipes.TileEntityPipe;
|
||||||
|
import basicpipes.pipes.TileEntityPump;
|
||||||
|
import cpw.mods.fml.common.Side;
|
||||||
|
import cpw.mods.fml.common.asm.SideOnly;
|
||||||
|
import cpw.mods.fml.common.network.IGuiHandler;
|
||||||
|
import cpw.mods.fml.common.registry.GameRegistry;
|
||||||
|
|
||||||
|
public class DevProxy implements IGuiHandler
|
||||||
|
{
|
||||||
|
@SideOnly(Side.CLIENT)
|
||||||
|
public void renders()
|
||||||
|
{
|
||||||
|
MinecraftForgeClient.preloadTexture("textures/Devblocks.png");
|
||||||
|
}
|
||||||
|
public void preInit()
|
||||||
|
{
|
||||||
|
renders();
|
||||||
|
}
|
||||||
|
public void init()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
public void postInit()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tileEntity != null)
|
||||||
|
{
|
||||||
|
switch(ID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||||
|
{
|
||||||
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
||||||
|
if (tileEntity != null)
|
||||||
|
{
|
||||||
|
switch(ID)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
37
src/common/aa/TileEntityAntiMob.java
Normal file
37
src/common/aa/TileEntityAntiMob.java
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
package aa;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import net.minecraft.src.AxisAlignedBB;
|
||||||
|
import net.minecraft.src.Entity;
|
||||||
|
import net.minecraft.src.EntityMob;
|
||||||
|
import net.minecraft.src.EntitySlime;
|
||||||
|
import net.minecraft.src.TileEntity;
|
||||||
|
|
||||||
|
public class TileEntityAntiMob extends TileEntity {
|
||||||
|
@Override
|
||||||
|
public void updateEntity()
|
||||||
|
{
|
||||||
|
List<Entity> ee = worldObj.loadedEntityList;
|
||||||
|
List<Entity> mobs = new ArrayList<Entity>();
|
||||||
|
for(int i = 0; i <ee.size(); i++)
|
||||||
|
{
|
||||||
|
if(ee.get(i) instanceof EntityMob || ee.get(i) instanceof EntitySlime)
|
||||||
|
{
|
||||||
|
mobs.add(ee.get(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(int j =0; j < mobs.size();j++)
|
||||||
|
{
|
||||||
|
Entity mod = mobs.get(j);
|
||||||
|
if(mod.getDistance(xCoord, yCoord, zCoord) < 40)
|
||||||
|
{
|
||||||
|
mobs.get(j).setDead();
|
||||||
|
mobs.remove(j);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
|
@ -71,7 +71,7 @@ public class BlockPipe extends BlockContainer
|
||||||
|
|
||||||
this.updateConductorTileEntity(world, x, y, z);
|
this.updateConductorTileEntity(world, x, y, z);
|
||||||
}
|
}
|
||||||
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side,Liquid type)
|
public static TileEntity getUEUnit(World world, int x, int y, int z, int side,Liquid type)
|
||||||
{
|
{
|
||||||
switch(side)
|
switch(side)
|
||||||
{
|
{
|
||||||
|
@ -129,7 +129,7 @@ public class BlockPipe extends BlockContainer
|
||||||
public static void updateConductorTileEntity(World world, int x, int y, int z)
|
public static void updateConductorTileEntity(World world, int x, int y, int z)
|
||||||
{
|
{
|
||||||
|
|
||||||
for(byte i = 0; i < 6; i++)
|
for(int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
//Update the tile entity on neighboring blocks
|
//Update the tile entity on neighboring blocks
|
||||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||||
|
|
|
@ -55,16 +55,12 @@ public class ItemGuage extends Item
|
||||||
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
||||||
Liquid type = pipeEntity.getType();
|
Liquid type = pipeEntity.getType();
|
||||||
int steam = pipeEntity.getStoredLiquid(type);
|
int steam = pipeEntity.getStoredLiquid(type);
|
||||||
|
int pressure = pipeEntity.presure;
|
||||||
String typeName = type.lName;
|
String typeName = type.lName;
|
||||||
String print = "Error";
|
String print = "Error";
|
||||||
if(steam <= 0)
|
|
||||||
{
|
print = typeName +" " + steam +" @ "+pressure+"PSI";
|
||||||
print = "No pressure or Volume";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print = typeName +" " + steam +" @ 16PSI";
|
|
||||||
}
|
|
||||||
par2EntityPlayer.addChatMessage(print);
|
par2EntityPlayer.addChatMessage(print);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,13 +36,7 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer,
|
||||||
}
|
}
|
||||||
public void updateEntity()
|
public void updateEntity()
|
||||||
{
|
{
|
||||||
if(energyStored > 100 && tickCount > 200 && waterStored < 10)
|
|
||||||
{
|
|
||||||
energyStored -= 100;
|
|
||||||
waterStored += 1;
|
|
||||||
tickCount = 0;
|
|
||||||
}
|
|
||||||
tickCount++;
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
|
public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
|
||||||
|
@ -65,7 +59,11 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer,
|
||||||
@Override
|
@Override
|
||||||
public void onUpdate(float amps, float voltage, ForgeDirection side) {
|
public void onUpdate(float amps, float voltage, ForgeDirection side) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
if(energyStored > 100 && waterStored < 10)
|
||||||
|
{
|
||||||
|
energyStored -= 100;
|
||||||
|
waterStored += 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public float ampRequest() {
|
public float ampRequest() {
|
||||||
|
@ -90,8 +88,24 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer,
|
||||||
@Override
|
@Override
|
||||||
public int getTickInterval() {
|
public int getTickInterval() {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
|
return 20;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -20,14 +20,15 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
//the current set type of the pipe 0-5
|
//the current set type of the pipe 0-5
|
||||||
protected Liquid type = Liquid.DEFUALT;
|
protected Liquid type = Liquid.DEFUALT;
|
||||||
//The maximum amount of electricity this conductor can take
|
//The maximum amount of electricity this conductor can take
|
||||||
protected int capacity = 5;
|
public int capacity = 2;
|
||||||
|
public int hPressure = this.presure;
|
||||||
private int count = 0;
|
private int count = 0;
|
||||||
private boolean intiUpdate = true;
|
private boolean intiUpdate = true;
|
||||||
//Stores information on all connected blocks around this tile entity
|
//Stores information on all connected blocks around this tile entity
|
||||||
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
||||||
|
|
||||||
//Checks if this is the first the tile entity updates
|
//Checks if this is the first the tile entity updates
|
||||||
protected boolean firstUpdate = true;
|
protected boolean firstUpdate = true;
|
||||||
|
public int presure = 0;
|
||||||
/**
|
/**
|
||||||
* This function adds a connection between this pipe and other blocks
|
* This function adds a connection between this pipe and other blocks
|
||||||
* @param tileEntity - Must be either a producer, consumer or a conductor
|
* @param tileEntity - Must be either a producer, consumer or a conductor
|
||||||
|
@ -35,60 +36,22 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
*/
|
*/
|
||||||
public void addConnection(TileEntity tileEntity, ForgeDirection side)
|
public void addConnection(TileEntity tileEntity, ForgeDirection side)
|
||||||
{
|
{
|
||||||
int sideN = getNumSide(side);
|
this.connectedBlocks[side.ordinal()] = null;
|
||||||
this.connectedBlocks[sideN] = null;
|
|
||||||
if(tileEntity instanceof ILiquidConsumer)
|
if(tileEntity instanceof ILiquidConsumer)
|
||||||
{
|
{
|
||||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side))
|
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side))
|
||||||
{
|
{
|
||||||
this.connectedBlocks[sideN] = tileEntity;
|
this.connectedBlocks[side.ordinal()] = tileEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(tileEntity instanceof ILiquidProducer)
|
if(tileEntity instanceof ILiquidProducer)
|
||||||
{
|
{
|
||||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
||||||
{
|
{
|
||||||
this.connectedBlocks[sideN] = tileEntity;
|
this.connectedBlocks[side.ordinal()] = tileEntity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private int getNumSide(ForgeDirection side)
|
|
||||||
{
|
|
||||||
|
|
||||||
if(side == ForgeDirection.DOWN)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
if(side == ForgeDirection.UP)
|
|
||||||
{
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if(side == ForgeDirection.NORTH)
|
|
||||||
{
|
|
||||||
return 2;
|
|
||||||
}
|
|
||||||
if(side == ForgeDirection.SOUTH)
|
|
||||||
{
|
|
||||||
return 3;
|
|
||||||
}
|
|
||||||
if(side == ForgeDirection.WEST)
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
if(side == ForgeDirection.EAST)
|
|
||||||
{
|
|
||||||
return 5;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* onRecieveLiquid is called whenever a something sends a volume to the pipe (which is this block).
|
* onRecieveLiquid is called whenever a something sends a volume to the pipe (which is this block).
|
||||||
* @param vols - The amount of vol source is trying to give to this pipe
|
* @param vols - The amount of vol source is trying to give to this pipe
|
||||||
|
@ -112,40 +75,73 @@ 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 >= 30 || intiUpdate)
|
if(count >= 10 || intiUpdate && !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;
|
intiUpdate = false;
|
||||||
}
|
|
||||||
if(!this.worldObj.isRemote)
|
|
||||||
{
|
int connectedUnits = 0;
|
||||||
byte connectedUnits = 0;
|
int pipes = 1;
|
||||||
byte connectedConductors = 1;
|
int producers = 0;
|
||||||
int averageVolume = this.liquidStored;
|
int averageVolume = this.liquidStored;
|
||||||
|
int averagePresure2 = 0;
|
||||||
|
|
||||||
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
|
for(int i = 0; i < 6; i++)
|
||||||
|
|
||||||
for(byte i = 0; i < 6; i++)
|
|
||||||
{
|
{
|
||||||
if(connectedBlocks[i] != null)
|
|
||||||
{
|
|
||||||
if(connectedBlocks[i] instanceof ILiquidConsumer || connectedBlocks[i] instanceof ILiquidProducer)
|
if(connectedBlocks[i] instanceof ILiquidConsumer || connectedBlocks[i] instanceof ILiquidProducer)
|
||||||
{
|
{
|
||||||
connectedUnits ++;
|
connectedUnits ++;
|
||||||
|
if(connectedBlocks[i] instanceof ILiquidProducer)
|
||||||
|
{
|
||||||
|
if(((ILiquidProducer)connectedBlocks[i]).canProducePresure(this.type, ForgeDirection.getOrientation(i)))
|
||||||
|
{
|
||||||
|
averagePresure2 += ((ILiquidProducer)connectedBlocks[i]).presureOutput(this.type,ForgeDirection.getOrientation(i));
|
||||||
|
producers++;
|
||||||
|
}
|
||||||
|
}else
|
||||||
if(connectedBlocks[i] instanceof TileEntityPipe)
|
if(connectedBlocks[i] instanceof TileEntityPipe)
|
||||||
{
|
{
|
||||||
|
pipes ++;
|
||||||
|
//add pipes volume to average collection value
|
||||||
averageVolume += ((TileEntityPipe)connectedBlocks[i]).liquidStored;
|
averageVolume += ((TileEntityPipe)connectedBlocks[i]).liquidStored;
|
||||||
|
//get the current pipes pressure
|
||||||
connectedConductors ++;
|
int pPressure = ((TileEntityPipe)connectedBlocks[i]).presure ;
|
||||||
|
if(pPressure > hPressure)
|
||||||
|
{
|
||||||
|
this.hPressure = pPressure;
|
||||||
|
}
|
||||||
|
}else
|
||||||
|
if(connectedBlocks[i] instanceof ILiquidConsumer)
|
||||||
|
{
|
||||||
|
if(this.presure <= 1)
|
||||||
|
{
|
||||||
|
this.hPressure = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
//turn average collection into actual average pipe volume
|
||||||
//average volume used to control volume spread to pipes. Prevent one pipe getting all liquid when another is empty
|
averageVolume = Math.max(averageVolume/pipes,0);
|
||||||
averageVolume = Math.max(averageVolume/connectedConductors,0);
|
|
||||||
|
|
||||||
|
//sets the pressure of the pipe to the producer pressure or to the highest pipe pressure -1
|
||||||
|
if(producers > 0)
|
||||||
|
{
|
||||||
|
averagePresure2 = Math.max(averagePresure2/producers,0);
|
||||||
|
this.presure = averagePresure2;
|
||||||
|
}
|
||||||
|
else
|
||||||
if(connectedUnits > 0)
|
if(connectedUnits > 0)
|
||||||
|
{
|
||||||
|
this.presure = hPressure - 1;
|
||||||
|
}else
|
||||||
|
{
|
||||||
|
this.presure = 1;
|
||||||
|
}
|
||||||
|
//only trade liquid if there is more than one thing connect and its pressure is higher than 1
|
||||||
|
if(connectedUnits > 0 && this.presure > 0)
|
||||||
{
|
{
|
||||||
for(byte i = 0; i < 6; i++)
|
for(byte i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
|
@ -159,14 +155,7 @@ 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 && this.liquidStored > ((TileEntityPipe)connectedConsumer).liquidStored)
|
transferVolumeAmount = this.liquidStored;
|
||||||
{
|
|
||||||
transferVolumeAmount = Math.max(Math.min(averageVolume - ((TileEntityPipe)connectedConsumer).liquidStored, this.liquidStored), 0);
|
|
||||||
}
|
|
||||||
else if(!(connectedConsumer instanceof TileEntityPipe))
|
|
||||||
{
|
|
||||||
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, 5), 0);
|
||||||
|
@ -184,6 +173,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -97,4 +97,22 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,4 +27,12 @@ public interface ILiquidProducer
|
||||||
* Also used for connection rules of pipes'
|
* Also used for connection rules of pipes'
|
||||||
*/
|
*/
|
||||||
public boolean canProduceLiquid(Liquid type, ForgeDirection side);
|
public boolean canProduceLiquid(Liquid type, ForgeDirection side);
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side);
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param type - liquid type
|
||||||
|
* @param side - side this of presure
|
||||||
|
* @return pressure that is used to output liquid on
|
||||||
|
*/
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side);
|
||||||
}
|
}
|
|
@ -12,19 +12,19 @@ public class ContainerBoiler extends Container
|
||||||
{
|
{
|
||||||
this.boiler = par2TileEntityboiler;
|
this.boiler = par2TileEntityboiler;
|
||||||
this.addSlotToContainer(new Slot(par2TileEntityboiler, 0, 56, 17));
|
this.addSlotToContainer(new Slot(par2TileEntityboiler, 0, 56, 17));
|
||||||
int var3;
|
int line;
|
||||||
|
|
||||||
for (var3 = 0; var3 < 3; ++var3)
|
for (line = 0; line < 3; ++line)
|
||||||
{
|
{
|
||||||
for (int var4 = 0; var4 < 9; ++var4)
|
for (int slot = 0; slot < 9; ++slot)
|
||||||
{
|
{
|
||||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
|
this.addSlotToContainer(new Slot(par1InventoryPlayer, slot + line * 9 + 9, 8 + slot * 18, 84 + line * 18));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (var3 = 0; var3 < 9; ++var3)
|
for (line = 0; line < 9; ++line)
|
||||||
{
|
{
|
||||||
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
|
this.addSlotToContainer(new Slot(par1InventoryPlayer, line, 8 + line * 18, 142));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -296,6 +296,29 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.STEAM)
|
||||||
|
{
|
||||||
|
if(side == ForgeDirection.UP)
|
||||||
|
{
|
||||||
|
return 100;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side)
|
||||||
|
{
|
||||||
|
if(type == Liquid.STEAM)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,7 +106,7 @@ public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{
|
||||||
@Override
|
@Override
|
||||||
public TileEntity createNewTileEntity(World world, int metadata)
|
public TileEntity createNewTileEntity(World world, int metadata)
|
||||||
{
|
{
|
||||||
if(metadata < 4)
|
if(metadata >= 0 && metadata < 4)
|
||||||
{
|
{
|
||||||
return new TileEntitySteamPiston();
|
return new TileEntitySteamPiston();
|
||||||
}
|
}
|
||||||
|
@ -119,13 +119,11 @@ public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{
|
||||||
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
public void onNeighborBlockChange(World par1World, int par2, int par3, int par4, int par5)
|
||||||
{
|
{
|
||||||
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
int meta = par1World.getBlockMetadata(par2, par3, par4);
|
||||||
boolean var7 = false;
|
|
||||||
if (meta == 1)
|
if (meta == 1)
|
||||||
{
|
{
|
||||||
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID)
|
||||||
{
|
{
|
||||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||||
var7 = true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -135,13 +133,6 @@ public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{
|
||||||
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
par1World.setBlockWithNotify(par2, par3, par4, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (var7)
|
|
||||||
{
|
|
||||||
if (!par1World.isRemote)
|
|
||||||
{
|
|
||||||
this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public int idDropped(int par1, Random par2Random, int par3)
|
public int idDropped(int par1, Random par2Random, int par3)
|
||||||
|
|
|
@ -50,7 +50,6 @@ public class ItemEngine extends Item
|
||||||
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
|
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
|
||||||
par3World.setBlockAndMetadataWithNotify(par4, par5+1, par6, var11.blockID, 14);
|
par3World.setBlockAndMetadataWithNotify(par4, par5+1, par6, var11.blockID, 14);
|
||||||
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
|
par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID);
|
||||||
ePlayer.sendChatToPlayer(""+par3World.getBlockMetadata(par4, par5, par6));
|
|
||||||
par3World.editingBlocks = false;
|
par3World.editingBlocks = false;
|
||||||
--par1ItemStack.stackSize;
|
--par1ItemStack.stackSize;
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -406,4 +406,21 @@ public class TileEntitySteamPiston extends TileEntityMachine implements IPacketR
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side)
|
||||||
|
{
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,5 +63,21 @@ public TileEntitySteamPiston genB = null;
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
return genB !=null ? genB.getLiquidCapacity(type): 0;
|
return genB !=null ? genB.getLiquidCapacity(type): 0;
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public int presureOutput(Liquid type, ForgeDirection side) {
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@Override
|
||||||
|
public boolean canProducePresure(Liquid type, ForgeDirection side)
|
||||||
|
{
|
||||||
|
if(type == Liquid.WATER)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
src/minecraft/textures/DevBlocks.png
Normal file
BIN
src/minecraft/textures/DevBlocks.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 30 KiB |
Loading…
Reference in a new issue