diff --git a/BasicPipesVersion.txt b/BasicPipesVersion.txt index e440e5c84..bf0d87ab1 100644 --- a/BasicPipesVersion.txt +++ b/BasicPipesVersion.txt @@ -1 +1 @@ -3 \ No newline at end of file +4 \ No newline at end of file diff --git a/SteamPowerVersion.txt b/SteamPowerVersion.txt index 62f945751..c7930257d 100644 --- a/SteamPowerVersion.txt +++ b/SteamPowerVersion.txt @@ -1 +1 @@ -6 \ No newline at end of file +7 \ No newline at end of file diff --git a/src/common/aa/BlockDev.java b/src/common/aa/BlockDev.java new file mode 100644 index 000000000..4258af025 --- /dev/null +++ b/src/common/aa/BlockDev.java @@ -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";} + +} diff --git a/src/common/aa/DevMain.java b/src/common/aa/DevMain.java new file mode 100644 index 000000000..90d25d1e6 --- /dev/null +++ b/src/common/aa/DevMain.java @@ -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(); + + } + +} diff --git a/src/common/aa/DevProxy.java b/src/common/aa/DevProxy.java new file mode 100644 index 000000000..12df3e467 --- /dev/null +++ b/src/common/aa/DevProxy.java @@ -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; + } +} \ No newline at end of file diff --git a/src/common/aa/TileEntityAntiMob.java b/src/common/aa/TileEntityAntiMob.java new file mode 100644 index 000000000..3837b9a83 --- /dev/null +++ b/src/common/aa/TileEntityAntiMob.java @@ -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 ee = worldObj.loadedEntityList; + List mobs = new ArrayList(); + for(int i = 0; i 100 && tickCount > 200 && waterStored < 10) - { - energyStored -= 100; - waterStored += 1; - tickCount = 0; - } - tickCount++; + } @Override public boolean canProduceLiquid(Liquid type, ForgeDirection side) { @@ -65,7 +59,11 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer, @Override public void onUpdate(float amps, float voltage, ForgeDirection side) { // TODO Auto-generated method stub - + if(energyStored > 100 && waterStored < 10) + { + energyStored -= 100; + waterStored += 1; + } } @Override public float ampRequest() { @@ -90,8 +88,24 @@ public class TileEntityCondenser extends TileEntity implements ILiquidProducer, @Override public int getTickInterval() { // TODO Auto-generated method stub + return 20; + } + @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; + } diff --git a/src/common/basicpipes/pipes/TileEntityPipe.java b/src/common/basicpipes/pipes/TileEntityPipe.java index d500f1574..4b12c8b0e 100644 --- a/src/common/basicpipes/pipes/TileEntityPipe.java +++ b/src/common/basicpipes/pipes/TileEntityPipe.java @@ -20,14 +20,15 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke //the current set type of the pipe 0-5 protected Liquid type = Liquid.DEFUALT; //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 boolean intiUpdate = true; //Stores information on all connected blocks around this tile entity public TileEntity[] connectedBlocks = {null, null, null, null, null, null}; - //Checks if this is the first the tile entity updates protected boolean firstUpdate = true; + public int presure = 0; /** * This function adds a connection between this pipe and other blocks * @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) { - int sideN = getNumSide(side); - this.connectedBlocks[sideN] = null; + this.connectedBlocks[side.ordinal()] = null; if(tileEntity instanceof ILiquidConsumer) { if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side)) { - this.connectedBlocks[sideN] = tileEntity; + this.connectedBlocks[side.ordinal()] = tileEntity; } } if(tileEntity instanceof ILiquidProducer) { 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). * @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 BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord); count++; - if(count >= 30 || intiUpdate) + if(count >= 10 || intiUpdate && !this.worldObj.isRemote) { PacketManager.sendTileEntityPacket(this, "Pipes", new Object[]{this.type.ordinal()}); count = 0; intiUpdate = false; - } - if(!this.worldObj.isRemote) - { - byte connectedUnits = 0; - byte connectedConductors = 1; - int averageVolume = this.liquidStored; + + + int connectedUnits = 0; + int pipes = 1; + int producers = 0; + int averageVolume = this.liquidStored; + int averagePresure2 = 0; - Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord); - - for(byte i = 0; i < 6; i++) + for(int i = 0; i < 6; i++) { - if(connectedBlocks[i] != null) - { if(connectedBlocks[i] instanceof ILiquidConsumer || connectedBlocks[i] instanceof ILiquidProducer) { 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) { + pipes ++; + //add pipes volume to average collection value averageVolume += ((TileEntityPipe)connectedBlocks[i]).liquidStored; - - connectedConductors ++; - } + //get the current pipes pressure + 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; + } + } } - } - } - //average volume used to control volume spread to pipes. Prevent one pipe getting all liquid when another is empty - averageVolume = Math.max(averageVolume/connectedConductors,0); + } + //turn average collection into actual average pipe volume + averageVolume = Math.max(averageVolume/pipes,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) + { + 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++) { @@ -159,14 +155,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke int transferVolumeAmount = 0; //amount to be moved ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]); - if(connectedBlocks[i] instanceof TileEntityPipe && this.liquidStored > ((TileEntityPipe)connectedConsumer).liquidStored) - { - transferVolumeAmount = Math.max(Math.min(averageVolume - ((TileEntityPipe)connectedConsumer).liquidStored, this.liquidStored), 0); - } - else if(!(connectedConsumer instanceof TileEntityPipe)) - { - transferVolumeAmount = this.liquidStored; - } + transferVolumeAmount = this.liquidStored; int rejectedVolume = connectedConsumer.onReceiveLiquid(this.type,transferVolumeAmount, ForgeDirection.getOrientation(i)); this.liquidStored = Math.max(Math.min(this.liquidStored - transferVolumeAmount + rejectedVolume, 5), 0); @@ -184,6 +173,7 @@ public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacke } } } + } } diff --git a/src/common/basicpipes/pipes/TileEntityPump.java b/src/common/basicpipes/pipes/TileEntityPump.java index 73ba3e831..4c2118511 100644 --- a/src/common/basicpipes/pipes/TileEntityPump.java +++ b/src/common/basicpipes/pipes/TileEntityPump.java @@ -97,4 +97,22 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro } 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; + } } diff --git a/src/common/basicpipes/pipes/api/ILiquidProducer.java b/src/common/basicpipes/pipes/api/ILiquidProducer.java index a0c376a49..4f5a94cd5 100644 --- a/src/common/basicpipes/pipes/api/ILiquidProducer.java +++ b/src/common/basicpipes/pipes/api/ILiquidProducer.java @@ -27,4 +27,12 @@ public interface ILiquidProducer * Also used for connection rules of pipes' */ 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); } \ No newline at end of file diff --git a/src/common/steampower/boiler/ContainerBoiler.java b/src/common/steampower/boiler/ContainerBoiler.java index b508543f4..86b512f42 100644 --- a/src/common/steampower/boiler/ContainerBoiler.java +++ b/src/common/steampower/boiler/ContainerBoiler.java @@ -12,19 +12,19 @@ public class ContainerBoiler extends Container { this.boiler = par2TileEntityboiler; 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)); } } diff --git a/src/common/steampower/boiler/TileEntityBoiler.java b/src/common/steampower/boiler/TileEntityBoiler.java index bd76d800c..c2f3b6d4a 100644 --- a/src/common/steampower/boiler/TileEntityBoiler.java +++ b/src/common/steampower/boiler/TileEntityBoiler.java @@ -296,6 +296,29 @@ public class TileEntityBoiler extends TileEntityMachine implements IPacketReceiv } 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; + } } diff --git a/src/common/steampower/turbine/BlockSteamPiston.java b/src/common/steampower/turbine/BlockSteamPiston.java index fda19383e..8792c4c43 100644 --- a/src/common/steampower/turbine/BlockSteamPiston.java +++ b/src/common/steampower/turbine/BlockSteamPiston.java @@ -106,7 +106,7 @@ public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{ @Override public TileEntity createNewTileEntity(World world, int metadata) { - if(metadata < 4) + if(metadata >= 0 && metadata < 4) { 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) { int meta = par1World.getBlockMetadata(par2, par3, par4); - boolean var7 = false; if (meta == 1) { if (par1World.getBlockId(par2, par3 + 1, par4) != this.blockID) { par1World.setBlockWithNotify(par2, par3, par4, 0); - var7 = true; } } else @@ -135,13 +133,6 @@ public class BlockSteamPiston extends universalelectricity.extend.BlockMachine{ par1World.setBlockWithNotify(par2, par3, par4, 0); } } - if (var7) - { - if (!par1World.isRemote) - { - this.dropBlockAsItem(par1World, par2, par3, par4, 0, 0); - } - } } @Override public int idDropped(int par1, Random par2Random, int par3) diff --git a/src/common/steampower/turbine/ItemEngine.java b/src/common/steampower/turbine/ItemEngine.java index 65b978f81..85189835d 100644 --- a/src/common/steampower/turbine/ItemEngine.java +++ b/src/common/steampower/turbine/ItemEngine.java @@ -50,7 +50,6 @@ public class ItemEngine extends Item par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID); par3World.setBlockAndMetadataWithNotify(par4, par5+1, par6, var11.blockID, 14); par3World.notifyBlocksOfNeighborChange(par4, par5, par6, var11.blockID); - ePlayer.sendChatToPlayer(""+par3World.getBlockMetadata(par4, par5, par6)); par3World.editingBlocks = false; --par1ItemStack.stackSize; return true; diff --git a/src/common/steampower/turbine/TileEntitySteamPiston.java b/src/common/steampower/turbine/TileEntitySteamPiston.java index 3650a226f..ecc3be2af 100644 --- a/src/common/steampower/turbine/TileEntitySteamPiston.java +++ b/src/common/steampower/turbine/TileEntitySteamPiston.java @@ -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; + } } diff --git a/src/common/steampower/turbine/TileEntitytopGen.java b/src/common/steampower/turbine/TileEntitytopGen.java index 421d812c0..8d9a24183 100644 --- a/src/common/steampower/turbine/TileEntitytopGen.java +++ b/src/common/steampower/turbine/TileEntitytopGen.java @@ -63,5 +63,21 @@ public TileEntitySteamPiston genB = null; // TODO Auto-generated method stub 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; + } } diff --git a/src/minecraft/textures/DevBlocks.png b/src/minecraft/textures/DevBlocks.png new file mode 100644 index 000000000..e1f3b762d Binary files /dev/null and b/src/minecraft/textures/DevBlocks.png differ