mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-18 19:39:14 +00:00
Merge branch 'master' into 1.7
This commit is contained in:
commit
fb27b3a7fe
6 files changed
+69
-24
No files matched your search
@@ -8,6 +8,7 @@ import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.FluidTankInfo;
|
||||
import net.minecraftforge.fluids.IFluidHandler;
|
||||
import buildcraft.api.transport.IPipeTile;
|
||||
import buildcraft.api.transport.IPipeTile.PipeType;
|
||||
@@ -241,6 +242,20 @@ public class AdvancedLiquidConduitNetwork extends AbstractTankConduitNetwork<Adv
|
||||
|
||||
FluidStack couldDrain = liquidType.copy();
|
||||
couldDrain.amount = maxExtract;
|
||||
|
||||
boolean foundFluid = false;
|
||||
FluidTankInfo[] info = extTank.getTankInfo(dir.getOpposite());
|
||||
if(info != null) {
|
||||
for (FluidTankInfo inf : info) {
|
||||
if(inf != null && inf.fluid != null && inf.fluid.amount > 0) {
|
||||
foundFluid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!foundFluid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FluidStack drained = extTank.drain(dir.getOpposite(), couldDrain, true);
|
||||
if(drained == null || drained.amount <= 0) {
|
||||
return false;
|
||||
|
||||
@@ -133,6 +133,20 @@ public class LiquidConduit extends AbstractTankConduit {
|
||||
|
||||
IFluidHandler extTank = getTankContainer(getLocation().getLocation(dir));
|
||||
if(extTank != null) {
|
||||
|
||||
boolean foundFluid = false;
|
||||
FluidTankInfo[] info = extTank.getTankInfo(dir.getOpposite());
|
||||
if(info != null) {
|
||||
for (FluidTankInfo inf : info) {
|
||||
if(inf != null && inf.fluid != null && inf.fluid.amount > 0) {
|
||||
foundFluid = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(!foundFluid) {
|
||||
return;
|
||||
}
|
||||
|
||||
FluidStack couldDrain = extTank.drain(dir.getOpposite(), MAX_EXTRACT_PER_TICK, false);
|
||||
if(couldDrain != null && couldDrain.amount > 0 && canFill(dir, couldDrain.getFluid())) {
|
||||
int used = pushLiquid(dir, couldDrain, true, network == null ? -1 : network.getNextPushToken());
|
||||
|
||||
@@ -169,12 +169,6 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
return PowerHandlerUtil.createHandler(CAPACITORS[subtype], this, Type.PIPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
|
||||
super.setConnectionMode(dir, mode);
|
||||
recievedTicks = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExtractionRedstoneMode(RedstoneControlMode mode, ForgeDirection dir) {
|
||||
rsModes.put(dir, mode);
|
||||
@@ -384,6 +378,12 @@ public class PowerConduit extends AbstractConduit implements IPowerConduit {
|
||||
return super.onNeighborBlockChange(blockId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConnectionMode(ForgeDirection dir, ConnectionMode mode) {
|
||||
super.setConnectionMode(dir, mode);
|
||||
recievedTicks = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate) {
|
||||
if(getMaxEnergyRecieved(from) == 0 || maxReceive <= 0) {
|
||||
|
||||
@@ -250,21 +250,26 @@ public class BlockCapacitorBank extends BlockEio implements IGuiHandler, IAdvanc
|
||||
|
||||
@Override
|
||||
public boolean removedByPlayer(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.getTileEntity(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.removedByPlayer(world, player, x, y, z);
|
||||
|
||||
@@ -773,6 +773,17 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
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);
|
||||
}
|
||||
@@ -799,8 +810,8 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
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;
|
||||
@@ -833,14 +844,14 @@ public class TileCapacitorBank extends TileEntityEio implements IInternalPowerRe
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user