From 19449065752689e8b8e57758a9191b97af8cf191 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Apr 2014 21:14:02 -0400 Subject: [PATCH 1/5] Change Ouput to Output --- resources/assets/enderio/lang/en_US.lang | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/assets/enderio/lang/en_US.lang b/resources/assets/enderio/lang/en_US.lang index bada3cf2..49a57903 100644 --- a/resources/assets/enderio/lang/en_US.lang +++ b/resources/assets/enderio/lang/en_US.lang @@ -173,7 +173,7 @@ enderio.gui.capBank.inputRs=Input Redstone Mode enderio.gui.capBank.outputRs=Output Redstone Mode enderio.gui.capBank.maxIo=Max I/O enderio.gui.capBank.maxInput=Max Input -enderio.gui.capBank.maxOutput=Max Ouput +enderio.gui.capBank.maxOutput=Max Output //Transceiver enderio.gui.trans.publicChannel=Public Channel From 1d5b93a320ffc1ed163d2414692e133532bed1d3 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Apr 2014 23:39:37 -0400 Subject: [PATCH 2/5] Fixed a bug for multiblock Cap banks in Creative Fixes a bug where multiblock capacitor banks do not update their multiblock configuration in creative. To duplicate original problem, switch to creative mode then create a single block capacitor bank, then attach another single block to create a multiblock, then remove the second capacitor bank to create a single block. The resulting single block capacitor has 200MJ/t and shows an outline which includes the deleted capacitor block area. --- .../machine/power/BlockCapacitorBank.java | 34 +++++++++++++------ .../machine/power/TileCapacitorBank.java | 4 +++ 2 files changed, 28 insertions(+), 10 deletions(-) diff --git a/common/crazypants/enderio/machine/power/BlockCapacitorBank.java b/common/crazypants/enderio/machine/power/BlockCapacitorBank.java index 052e9bd9..d12836c4 100644 --- a/common/crazypants/enderio/machine/power/BlockCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/BlockCapacitorBank.java @@ -236,23 +236,36 @@ public class BlockCapacitorBank extends Block implements ITileEntityProvider, IG @Override public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) { - if(!world.isRemote && (!player.capabilities.isCreativeMode || "true".equalsIgnoreCase(System.getProperty("blockCapBankAllwaysDrop")))) { + System.out.println("Block removed by player at "+x+", "+y+", "+z); + System.out.println("world.isRemote: "+world.isRemote); + + if(!world.isRemote) { + System.out.println("I care now!"); + TileEntity te = world.getBlockTileEntity(x, y, z); + if(te instanceof TileCapacitorBank) { TileCapacitorBank cb = (TileCapacitorBank) te; cb.onBreakBlock(); - ItemStack itemStack = - BlockItemCapacitorBank.createItemStackWithPower(cb.doGetEnergyStored()); - float f = 0.7F; - double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; - double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; - double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; - EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack); - entityitem.delayBeforeCanPickup = 10; - world.spawnEntityInWorld(entityitem); + // If we are not in Creative or blockCapBankAllwaysDrop is set to true, allow the item drop. + // This option allows creative players to pick up broken capacitor banks + + if (!player.capabilities.isCreativeMode || "true".equalsIgnoreCase(System.getProperty("blockCapBankAllwaysDrop"))) { + ItemStack itemStack = + BlockItemCapacitorBank.createItemStackWithPower(cb.doGetEnergyStored()); + float f = 0.7F; + double d0 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d1 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + double d2 = world.rand.nextFloat() * f + (1.0F - f) * 0.5D; + EntityItem entityitem = new EntityItem(world, x + d0, y + d1, z + d2, itemStack); + entityitem.delayBeforeCanPickup = 10; + world.spawnEntityInWorld(entityitem); + } } } + + System.out.println("Super!"); return super.removeBlockByPlayer(world, player, x, y, z); } @@ -281,6 +294,7 @@ public class BlockCapacitorBank extends Block implements ITileEntityProvider, IG @Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { + System.out.println("Break block!"); if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { TileEntity te = world.getBlockTileEntity(x, y, z); if(!(te instanceof TileCapacitorBank)) { diff --git a/common/crazypants/enderio/machine/power/TileCapacitorBank.java b/common/crazypants/enderio/machine/power/TileCapacitorBank.java index 46653ac1..06b4d81a 100644 --- a/common/crazypants/enderio/machine/power/TileCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/TileCapacitorBank.java @@ -709,6 +709,7 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep } public void onBreakBlock() { + System.out.println("On break block!!!!!!!!!!!!!!!"); TileCapacitorBank controller = getController(); controller.clearCurrentMultiblock(); } @@ -763,7 +764,10 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep private void setMultiblock(BlockCoord[] mb) { + if (mb != null) + System.out.println("Incoming multiblock size: "+mb.length); if(multiblock != null && isMaster()) { + // split up current multiblock and reconfigure all the internal capacitors float powerPerBlock = storedEnergy / multiblock.length; for (BlockCoord bc : multiblock) { From b4bb9c201176035e5bddb4f6b971e4f2ed2c78b3 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Apr 2014 23:44:42 -0400 Subject: [PATCH 3/5] Clean up debug statements --- .../enderio/machine/power/BlockCapacitorBank.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/common/crazypants/enderio/machine/power/BlockCapacitorBank.java b/common/crazypants/enderio/machine/power/BlockCapacitorBank.java index d12836c4..294fd187 100644 --- a/common/crazypants/enderio/machine/power/BlockCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/BlockCapacitorBank.java @@ -236,12 +236,7 @@ public class BlockCapacitorBank extends Block implements ITileEntityProvider, IG @Override public boolean removeBlockByPlayer(World world, EntityPlayer player, int x, int y, int z) { - System.out.println("Block removed by player at "+x+", "+y+", "+z); - System.out.println("world.isRemote: "+world.isRemote); - if(!world.isRemote) { - System.out.println("I care now!"); - TileEntity te = world.getBlockTileEntity(x, y, z); if(te instanceof TileCapacitorBank) { @@ -265,7 +260,6 @@ public class BlockCapacitorBank extends Block implements ITileEntityProvider, IG } } - System.out.println("Super!"); return super.removeBlockByPlayer(world, player, x, y, z); } @@ -294,7 +288,6 @@ public class BlockCapacitorBank extends Block implements ITileEntityProvider, IG @Override public void breakBlock(World world, int x, int y, int z, int par5, int par6) { - System.out.println("Break block!"); if(!world.isRemote && world.getGameRules().getGameRuleBooleanValue("doTileDrops")) { TileEntity te = world.getBlockTileEntity(x, y, z); if(!(te instanceof TileCapacitorBank)) { From bda094460c952e8142ee71d6c17a963d6f7559b1 Mon Sep 17 00:00:00 2001 From: Liam Date: Tue, 29 Apr 2014 23:48:55 -0400 Subject: [PATCH 4/5] Cleanup of debug code --- .../crazypants/enderio/machine/power/TileCapacitorBank.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/common/crazypants/enderio/machine/power/TileCapacitorBank.java b/common/crazypants/enderio/machine/power/TileCapacitorBank.java index 06b4d81a..f5aa469c 100644 --- a/common/crazypants/enderio/machine/power/TileCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/TileCapacitorBank.java @@ -709,7 +709,6 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep } public void onBreakBlock() { - System.out.println("On break block!!!!!!!!!!!!!!!"); TileCapacitorBank controller = getController(); controller.clearCurrentMultiblock(); } @@ -763,11 +762,7 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep } private void setMultiblock(BlockCoord[] mb) { - - if (mb != null) - System.out.println("Incoming multiblock size: "+mb.length); if(multiblock != null && isMaster()) { - // split up current multiblock and reconfigure all the internal capacitors float powerPerBlock = storedEnergy / multiblock.length; for (BlockCoord bc : multiblock) { From 710501f3e2389b731950c4a2ac03c6b4c739f2f0 Mon Sep 17 00:00:00 2001 From: Liam Date: Wed, 30 Apr 2014 00:56:04 -0400 Subject: [PATCH 5/5] Makes cap upgrades remember their limits This change makes capacitor banks remember the limits which were set to them before being expanded. This way, a single block capacitor bank with an IO of 100MJ/t and user-specified output of 50 MJ/t, when expanded with another bank next to it will become a bank with IO of 200MJ/t and user-specified output of... 50MJ/t! However, if you have a bank which has maximum input or output, that will expand. Since input and output is handled seperately, you can have an output limit while still expanding the input limit. --- .../machine/power/TileCapacitorBank.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/common/crazypants/enderio/machine/power/TileCapacitorBank.java b/common/crazypants/enderio/machine/power/TileCapacitorBank.java index f5aa469c..f4106e27 100644 --- a/common/crazypants/enderio/machine/power/TileCapacitorBank.java +++ b/common/crazypants/enderio/machine/power/TileCapacitorBank.java @@ -745,6 +745,17 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep mb[i] = new BlockCoord(blocks.get(i)); } + TileCapacitorBank secondary = blocks.get(1); + maxInput = maxOutput = -1; + + if (secondary.maxInput != secondary.maxIO) { + maxInput = secondary.maxInput; + } + + if (secondary.maxOutput != secondary.maxIO) { + maxOutput = secondary.maxOutput; + } + for (TileCapacitorBank cb : blocks) { cb.setMultiblock(mb); } @@ -770,8 +781,8 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep if(cb != null) { cb.maxStoredEnergy = BASE_CAP.getMaxEnergyStored(); cb.maxIO = BASE_CAP.getMaxEnergyExtracted(); - cb.maxInput = cb.maxIO; - cb.maxOutput = cb.maxIO; + cb.maxInput = Math.min(cb.maxInput, cb.maxIO); + cb.maxOutput = Math.min(cb.maxOutput, cb.maxIO); cb.storedEnergy = powerPerBlock; cb.updatePowerHandler(); cb.multiblockDirty = true; @@ -804,14 +815,15 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep storedEnergy = totalStored; maxStoredEnergy = totalCap; maxIO = totalIO; - maxInput = maxIO; - maxOutput = maxIO; + maxInput = maxInput < 0 ? maxIO : Math.min(maxInput, maxIO); + maxOutput = maxOutput < 0 ? maxIO : Math.min(maxOutput, maxIO); + for (BlockCoord bc : multiblock) { TileCapacitorBank cb = getCapBank(bc); - if(cb != null) { + if(cb != null && cb != this) { cb.maxIO = totalIO; - cb.maxInput = maxIO; - cb.maxOutput = maxIO; + cb.maxInput = maxInput; + cb.maxOutput = maxOutput; } } @@ -1002,7 +1014,7 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep render = true; } } - + maxIO = nbtRoot.getInteger("maxIO"); if(nbtRoot.hasKey("maxInput")) { maxInput = nbtRoot.getInteger("maxInput");