From 3abd80f1a2ff43a7ccb6a535d107a231fc41378d Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 19:10:17 -0400 Subject: [PATCH 1/3] Generators now sustain fluid and gas data --- .../common/block/BlockGenerator.java | 9 +++++++-- .../common/item/ItemBlockGenerator.java | 10 +++++++++- .../common/tile/TileEntityBioGenerator.java | 15 ++++++++++++++- .../common/tile/TileEntityGasGenerator.java | 19 +++++++++++++++++-- .../common/tile/TileEntityHeatGenerator.java | 18 +++++++++++++++++- 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index cc31bc86d..0f94d9688 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -7,6 +7,7 @@ import mekanism.api.energy.IEnergizedItem; import mekanism.common.IActiveState; import mekanism.common.IBoundingBlock; import mekanism.common.ISpecialBounds; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.ItemAttacher; @@ -18,8 +19,8 @@ import mekanism.generators.client.GeneratorsClientProxy; import mekanism.generators.common.MekanismGenerators; import mekanism.generators.common.tile.TileEntityAdvancedSolarGenerator; import mekanism.generators.common.tile.TileEntityBioGenerator; -import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntityGasGenerator; +import mekanism.generators.common.tile.TileEntityHeatGenerator; import mekanism.generators.common.tile.TileEntitySolarGenerator; import mekanism.generators.common.tile.TileEntityWindTurbine; import net.minecraft.block.Block; @@ -39,7 +40,6 @@ import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.tools.IToolWrench; - import cpw.mods.fml.common.ModAPIManager; import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.SideOnly; @@ -459,6 +459,11 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds ISustainedInventory inventory = (ISustainedInventory)itemStack.getItem(); inventory.setInventory(((ISustainedInventory)tileEntity).getInventory(), itemStack); + + if(tileEntity instanceof ISustainedData) + { + ((ISustainedData)tileEntity).writeSustainedData(itemStack); + } if(((ISustainedTank)itemStack.getItem()).hasTank(itemStack)) { diff --git a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java index 33e373e8f..83b05f678 100644 --- a/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java +++ b/src/main/java/mekanism/generators/common/item/ItemBlockGenerator.java @@ -8,6 +8,7 @@ import java.util.List; import mekanism.api.EnumColor; import mekanism.api.energy.IEnergizedItem; import mekanism.client.MekanismKeyHandler; +import mekanism.common.ISustainedData; import mekanism.common.ISustainedInventory; import mekanism.common.ISustainedTank; import mekanism.common.Mekanism; @@ -31,7 +32,6 @@ import net.minecraftforge.fluids.FluidStack; import org.lwjgl.input.Keyboard; import cofh.api.energy.IEnergyContainerItem; - import cpw.mods.fml.common.Optional.Interface; import cpw.mods.fml.common.Optional.InterfaceList; import cpw.mods.fml.common.Optional.Method; @@ -169,6 +169,14 @@ public class ItemBlockGenerator extends ItemBlock implements IEnergizedItem, ISp tileEntity.electricityStored = getEnergy(stack); ((ISustainedInventory)tileEntity).setInventory(getInventory(stack)); + + if(tileEntity instanceof ISustainedData) + { + if(stack.stackTagCompound != null) + { + ((ISustainedData)tileEntity).readSustainedData(stack); + } + } if(tileEntity instanceof ISustainedTank) { diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java index 916fab482..33170f7a6 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityBioGenerator.java @@ -7,6 +7,7 @@ import java.util.EnumSet; import mekanism.client.sound.TileSound; import mekanism.common.FluidSlot; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; @@ -26,7 +27,7 @@ import cpw.mods.fml.relauncher.SideOnly; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler +public class TileEntityBioGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData { /** The Sound instance for this machine. */ @SideOnly(Side.CLIENT) @@ -317,4 +318,16 @@ public class TileEntityBioGenerator extends TileEntityGenerator implements IFlui { return null; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + itemStack.stackTagCompound.setInteger("fluidStored", bioFuelSlot.fluidStored); + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + bioFuelSlot.setFluid(itemStack.stackTagCompound.getInteger("fluidStored")); + } } \ No newline at end of file diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java index e04492126..db53d2050 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityGasGenerator.java @@ -14,6 +14,7 @@ import mekanism.api.gas.GasTransmission; import mekanism.api.gas.IGasHandler; import mekanism.api.gas.IGasItem; import mekanism.api.gas.ITubeConnection; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.MekanismUtils; @@ -21,11 +22,10 @@ import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraftforge.common.util.ForgeDirection; import cpw.mods.fml.common.Optional.Method; - import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection +public class TileEntityGasGenerator extends TileEntityGenerator implements IGasHandler, ITubeConnection, ISustainedData { /** The maximum amount of gas this block can store. */ public int MAX_GAS = 18000; @@ -277,4 +277,19 @@ public class TileEntityGasGenerator extends TileEntityGenerator implements IGasH { return side != ForgeDirection.getOrientation(facing); } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(fuelTank.getGas() != null) + { + itemStack.stackTagCompound.setTag("fuelTank", fuelTank.write(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + fuelTank.setGas(GasStack.readFromNBT(itemStack.stackTagCompound.getCompoundTag("fuelTank"))); + } } diff --git a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java index 92af05136..84216e171 100644 --- a/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java +++ b/src/main/java/mekanism/generators/common/tile/TileEntityHeatGenerator.java @@ -4,6 +4,7 @@ import io.netty.buffer.ByteBuf; import java.util.ArrayList; +import mekanism.common.ISustainedData; import mekanism.common.Mekanism; import mekanism.common.util.ChargeUtils; import mekanism.common.util.FluidContainerUtils; @@ -27,7 +28,7 @@ import cpw.mods.fml.common.Optional.Method; import dan200.computercraft.api.lua.ILuaContext; import dan200.computercraft.api.peripheral.IComputerAccess; -public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler +public class TileEntityHeatGenerator extends TileEntityGenerator implements IFluidHandler, ISustainedData { /** The FluidTank for this generator. */ public FluidTank lavaTank = new FluidTank(24000); @@ -335,4 +336,19 @@ public class TileEntityHeatGenerator extends TileEntityGenerator implements IFlu { return new FluidTankInfo[] {lavaTank.getInfo()}; } + + @Override + public void writeSustainedData(ItemStack itemStack) + { + if(lavaTank.getFluid() != null) + { + itemStack.stackTagCompound.setTag("lavaTank", lavaTank.getFluid().writeToNBT(new NBTTagCompound())); + } + } + + @Override + public void readSustainedData(ItemStack itemStack) + { + lavaTank.setFluid(FluidStack.loadFluidStackFromNBT(itemStack.stackTagCompound.getCompoundTag("lavaTank"))); + } } From 31e24ecd1ef7cffae667757a9072e7c9dc6b6807 Mon Sep 17 00:00:00 2001 From: "Aidan C. Brady" Date: Sat, 26 Jul 2014 19:17:02 -0400 Subject: [PATCH 2/3] Fixed default enchantibilities --- .../mekanism/tools/common/MekanismTools.java | 36 +++++++++---------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/main/java/mekanism/tools/common/MekanismTools.java b/src/main/java/mekanism/tools/common/MekanismTools.java index 06e80815d..930303c33 100644 --- a/src/main/java/mekanism/tools/common/MekanismTools.java +++ b/src/main/java/mekanism/tools/common/MekanismTools.java @@ -394,84 +394,84 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "maxUses", 2500).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "efficiency", 20d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.regular", "enchantability", 40).getInt() ); toolOBSIDIAN2 = EnumHelper.addToolMaterial("OBSIDIAN2" , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "maxUses", 3000).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "efficiency", 25d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.obsidian.paxel", "enchantability", 50).getInt() ); toolLAZULI = EnumHelper.addToolMaterial("LAZULI" , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "maxUses", 200).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.lapis.regular", "efficiency", 5d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "damage", 2).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 22).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.regular", "enchantability", 8).getInt() ); toolLAZULI2 = EnumHelper.addToolMaterial("LAZULI2" , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "maxUses", 250).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "efficiency", 6d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.tool-balance.lapis.paxel", "enchantability", 10).getInt() ); toolOSMIUM = EnumHelper.addToolMaterial("OSMIUM" , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "maxUses", 500).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.osmium.regular", "efficiency", 10d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 30).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.regular", "enchantability", 12).getInt() ); toolOSMIUM2 = EnumHelper.addToolMaterial("OSMIUM2" , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "maxUses", 700).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "efficiency", 12d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 40).getInt() + , Mekanism.configuration.get("tools.tool-balance.osmium.paxel", "enchantability", 16).getInt() ); toolBRONZE = EnumHelper.addToolMaterial("BRONZE" , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "maxUses", 800).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.bronze.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "damage", 6).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.regular", "enchantability", 10).getInt() ); toolBRONZE2 = EnumHelper.addToolMaterial("BRONZE2" , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "maxUses", 1100).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "efficiency", 16d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "damage", 10).getInt() - , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.bronze.paxel", "enchantability", 14).getInt() ); toolGLOWSTONE = EnumHelper.addToolMaterial("GLOWSTONE" , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "maxUses", 300).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 80).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.regular", "enchantability", 18).getInt() ); toolGLOWSTONE2 = EnumHelper.addToolMaterial("GLOWSTONE2" , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "harvestLevel", 2).getInt() , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "maxUses", 450).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "efficiency", 18d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "damage", 5).getInt() - , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.glowstone.paxel", "enchantability", 22).getInt() ); toolSTEEL = EnumHelper.addToolMaterial("STEEL" , Mekanism.configuration.get("tools.tool-balance.steel.regular", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.steel.regular", "maxUses", 850).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.steel.regular", "efficiency", 14d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.steel.regular", "damage", 4).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.regular", "enchantability", 10).getInt() ); toolSTEEL2 = EnumHelper.addToolMaterial("STEEL2" , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "harvestLevel", 3).getInt() , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "maxUses", 1250).getInt() , (float)Mekanism.configuration.get("tools.tool-balance.steel.paxel", "efficiency", 18d).getDouble(0) , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "damage", 8).getInt() - , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 100).getInt() + , Mekanism.configuration.get("tools.tool-balance.steel.paxel", "enchantability", 14).getInt() ); //Armors @@ -484,7 +484,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "legs", 8).getInt() , Mekanism.configuration.get("tools.armor-balance.obsidian.protection", "feet", 5).getInt() } - , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.obsidian", "enchantability", 40).getInt() ); armorLAZULI = EnumHelper.addArmorMaterial("LAZULI" , Mekanism.configuration.get("tools.armor-balance.lapis", "durability", 13).getInt() @@ -495,7 +495,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.lapis.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.lapis", "enchantability", 8).getInt() ); armorOSMIUM = EnumHelper.addArmorMaterial("OSMIUM" , Mekanism.configuration.get("tools.armor-balance.osmium", "durability", 30).getInt() @@ -506,7 +506,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.osmium.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.osmium", "enchantability", 12).getInt() ); armorBRONZE = EnumHelper.addArmorMaterial("BRONZE" , Mekanism.configuration.get("tools.armor-balance.bronze", "durability", 35).getInt() @@ -517,7 +517,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "legs", 5).getInt() , Mekanism.configuration.get("tools.armor-balance.bronze.protection", "feet", 2).getInt() } - , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.bronze", "enchantability", 10).getInt() ); armorGLOWSTONE = EnumHelper.addArmorMaterial("GLOWSTONE" , Mekanism.configuration.get("tools.armor-balance.glowstone", "durability", 18).getInt() @@ -528,7 +528,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.glowstone.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.glowstone", "enchantability", 18).getInt() ); armorSTEEL = EnumHelper.addArmorMaterial("STEEL" , Mekanism.configuration.get("tools.armor-balance.steel", "durability", 40).getInt() @@ -539,7 +539,7 @@ public class MekanismTools implements IModule , Mekanism.configuration.get("tools.armor-balance.steel.protection", "legs", 6).getInt() , Mekanism.configuration.get("tools.armor-balance.steel.protection", "feet", 3).getInt() } - , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 50).getInt() + , Mekanism.configuration.get("tools.armor-balance.steel", "enchantability", 10).getInt() ); //Bronze From 1d61c3d4e8696ad568766a970daaff843fc4ee5b Mon Sep 17 00:00:00 2001 From: Ben Spiers Date: Sun, 27 Jul 2014 20:45:13 +0100 Subject: [PATCH 3/3] Tweak energynet logic a bit to safeguard against overly high tiers of IC2 acceptor and things that implement everything but with only one working. Should fix AE2 EU P2P tunnel support. --- .../java/mekanism/common/EnergyNetwork.java | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/src/main/java/mekanism/common/EnergyNetwork.java b/src/main/java/mekanism/common/EnergyNetwork.java index 11b012149..f83a19a6b 100644 --- a/src/main/java/mekanism/common/EnergyNetwork.java +++ b/src/main/java/mekanism/common/EnergyNetwork.java @@ -201,21 +201,26 @@ public class EnergyNetwork extends DynamicNetwork if(acceptor instanceof IStrictEnergyAcceptor) { - sent += ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); + double used = ((IStrictEnergyAcceptor)acceptor).transferEnergyToAcceptor(side.getOpposite(), currentSending); + sent += used; + if(used > 0) continue; } - else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) + if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; int used = handler.receiveEnergy(side.getOpposite(), (int)Math.round(currentSending*Mekanism.TO_TE), false); sent += used*Mekanism.FROM_TE; + if(used > 0) continue; } - else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) + if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { - double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(((IEnergySink) acceptor).getSinkTier())*Mekanism.FROM_IC2); + double toSend = Math.min(currentSending, EnergyNet.instance.getPowerFromTier(Math.min(((IEnergySink) acceptor).getSinkTier(), 8))*Mekanism.FROM_IC2); toSend = Math.min(toSend, ((IEnergySink)acceptor).getDemandedEnergy()*Mekanism.FROM_IC2); - sent += (toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2)); + double used = toSend - (((IEnergySink)acceptor).injectEnergy(side.getOpposite(), toSend*Mekanism.TO_IC2, 0)*Mekanism.FROM_IC2); + sent += used; + if(used > 0) continue; } - else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) + if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { PowerReceiver receiver = ((IPowerReceptor)acceptor).getPowerReceiver(side.getOpposite()); @@ -223,6 +228,7 @@ public class EnergyNetwork extends DynamicNetwork { double toSend = receiver.receiveEnergy(Type.PIPE, (float)(Math.min(receiver.powerRequest(), currentSending*Mekanism.TO_BC)), side.getOpposite()); sent += toSend*Mekanism.FROM_BC; + if(toSend > 0) continue; } } } @@ -260,10 +266,11 @@ public class EnergyNetwork extends DynamicNetwork if(handler.getMaxEnergy() - handler.getEnergy() > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) + if(MekanismUtils.useRF() && acceptor instanceof IEnergyHandler) { IEnergyHandler handler = (IEnergyHandler)acceptor; @@ -272,22 +279,27 @@ public class EnergyNetwork extends DynamicNetwork if(handler.getMaxEnergyStored(side.getOpposite()) - handler.getEnergyStored(side.getOpposite()) > 0 || handler.receiveEnergy(side.getOpposite(), 1, true) > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) + if(MekanismUtils.useIC2() && acceptor instanceof IEnergySink) { IEnergySink handler = (IEnergySink)acceptor; if(handler.acceptsEnergyFrom(null, side.getOpposite())) { - if(Math.min((handler.getDemandedEnergy()*Mekanism.FROM_IC2), (EnergyNet.instance.getPowerFromTier(handler.getSinkTier())*Mekanism.FROM_IC2)) > 0) + double demanded = handler.getDemandedEnergy()*Mekanism.FROM_IC2; + int tier = Math.min(handler.getSinkTier(), 8); + double max = EnergyNet.instance.getPowerFromTier(tier)*Mekanism.FROM_IC2; + if(Math.min(demanded, max) > 0) { toReturn.add(acceptor); + continue; } } } - else if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) + if(MekanismUtils.useBuildCraft() && acceptor instanceof IPowerReceptor) { IPowerReceptor handler = (IPowerReceptor)acceptor; @@ -301,6 +313,7 @@ public class EnergyNetwork extends DynamicNetwork } toReturn.add(acceptor); + continue; } } }