Merge pull request #630 from rezonant/capacitors

Capacitor bank fixes
This commit is contained in:
CrazyPants committed 2014-05-01 12:19:16 +08:00
commit 97e679cd41
3 files changed
+38 -20

No files matched your search

@@ -236,23 +236,30 @@ 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")))) {
if(!world.isRemote) {
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);
}
}
}
return super.removeBlockByPlayer(world, player, x, y, z);
}
@@ -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);
}
@@ -762,7 +773,6 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep
}
private void setMultiblock(BlockCoord[] mb) {
if(multiblock != null && isMaster()) {
// split up current multiblock and reconfigure all the internal capacitors
float powerPerBlock = storedEnergy / multiblock.length;
@@ -771,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;
@@ -805,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;
}
}
@@ -1003,7 +1014,7 @@ public class TileCapacitorBank extends TileEntity implements IInternalPowerRecep
render = true;
}
}
maxIO = nbtRoot.getInteger("maxIO");
if(nbtRoot.hasKey("maxInput")) {
maxInput = nbtRoot.getInteger("maxInput");
+1 -1
View File
@@ -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