diff --git a/src/main/java/mekanism/common/block/BlockEnergyCube.java b/src/main/java/mekanism/common/block/BlockEnergyCube.java index c1b6a9c6c..e5013bb16 100644 --- a/src/main/java/mekanism/common/block/BlockEnergyCube.java +++ b/src/main/java/mekanism/common/block/BlockEnergyCube.java @@ -251,17 +251,6 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid return itemStack; } - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote && MekanismUtils.useIC2()) - { - ((TileEntityElectricBlock)tileEntity).register(); - } - } - public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock) { ItemStack itemStack = getPickBlock(null, world, x, y, z); diff --git a/src/main/java/mekanism/common/block/BlockMachine.java b/src/main/java/mekanism/common/block/BlockMachine.java index 59c649489..5551c4b29 100644 --- a/src/main/java/mekanism/common/block/BlockMachine.java +++ b/src/main/java/mekanism/common/block/BlockMachine.java @@ -1124,20 +1124,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer return true; } - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote) - { - if(tileEntity instanceof TileEntityElectricBlock && MekanismUtils.useIC2()) - { - ((TileEntityElectricBlock)tileEntity).register(); - } - } - } - public static enum MachineType { ENRICHMENT_CHAMBER(Mekanism.MachineBlock, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, true, false, true), diff --git a/src/main/java/mekanism/common/integration/MekanismHooks.java b/src/main/java/mekanism/common/integration/MekanismHooks.java index c42a8fcdd..2f2b4e09f 100644 --- a/src/main/java/mekanism/common/integration/MekanismHooks.java +++ b/src/main/java/mekanism/common/integration/MekanismHooks.java @@ -30,8 +30,6 @@ import ic2.api.recipe.Recipes; */ public final class MekanismHooks { - private Class BasicComponents; - private Class BuildCraftEnergy; public boolean IC2Loaded = false; @@ -80,7 +78,7 @@ public final class MekanismHooks } - @Method(modid = "IC2API") + @Method(modid = "IC2") public void hookIC2Recipes() { for(Map.Entry entry : Recipes.macerator.getRecipes().entrySet()) diff --git a/src/main/java/mekanism/common/integration/OreDictManager.java b/src/main/java/mekanism/common/integration/OreDictManager.java index 6ce3e49a6..2275ed592 100644 --- a/src/main/java/mekanism/common/integration/OreDictManager.java +++ b/src/main/java/mekanism/common/integration/OreDictManager.java @@ -398,7 +398,7 @@ public final class OreDictManager try { RecipeHandler.addCrusherRecipe(new ItemStack(Mekanism.Ingot, 1, 2), MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); - if(Mekanism.hooks.IC2APILoaded) + if(Mekanism.hooks.IC2Loaded) { addIC2BronzeRecipe(); } @@ -506,7 +506,7 @@ public final class OreDictManager } - @Method(modid = "IC2API") + @Method(modid = "IC2") public static void addIC2BronzeRecipe() { try { diff --git a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java index 5727da9fc..45163e03c 100644 --- a/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java +++ b/src/main/java/mekanism/common/tile/TileEntityElectricBlock.java @@ -4,6 +4,7 @@ import ic2.api.energy.EnergyNet; import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.tile.IEnergySink; +import ic2.api.energy.tile.IEnergySource; import ic2.api.energy.tile.IEnergyTile; import ic2.api.tile.IEnergyStorage; import io.netty.buffer.ByteBuf; @@ -16,7 +17,6 @@ import mekanism.api.energy.ICableOutputter; import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.transmitters.IGridTransmitter; -import mekanism.common.EnergyNetwork.EnergyTransferEvent; import mekanism.common.ITileNetwork; import mekanism.common.Mekanism; import mekanism.common.util.MekanismUtils; @@ -42,7 +42,7 @@ import cofh.api.energy.IEnergyHandler; @Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"), @Interface(iface = "buildcraft.api.power.IPowerEmitter", modid = "BuildCraftAPI|power") }) -public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter +public abstract class TileEntityElectricBlock extends TileEntityContainerBlock implements ITileNetwork, IPowerEmitter, IPowerReceptor, IStrictEnergyStorage, IEnergyHandler, IEnergySink, IEnergySource, IEnergyStorage, IStrictEnergyAcceptor, ICableOutputter { /** How much energy is stored in this block. */ public double electricityStored; @@ -226,7 +226,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "BuildCraftAPI|power") protected void reconfigure() { - powerHandler.configure(0, (float)((getMaxEnergy()-getEnergy())*Mekanism.TO_BC), 0, (float)(getMaxEnergy()*Mekanism.TO_BC)); + powerHandler.configure(0, (float)((getMaxEnergy() - getEnergy()) * Mekanism.TO_BC), 0, (float)(getMaxEnergy() * Mekanism.TO_BC)); } @Override @@ -329,6 +329,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i return 4; } + @Override + @Method(modid = "IC2") + public int getSourceTier() + { + return 4; + } + @Override @Method(modid = "IC2") public void setStored(int energy) @@ -361,21 +368,28 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) { - return !getOutputtingSides().contains(direction); + return getConsumingSides().contains(direction); + } + + @Override + @Method(modid = "IC2") + public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction) + { + return getOutputtingSides().contains(direction); } @Override @Method(modid = "IC2") public int getStored() { - return (int)Math.round(getEnergy()*Mekanism.TO_IC2); + return (int)Math.round(getEnergy() * Mekanism.TO_IC2); } @Override @Method(modid = "IC2") public int getCapacity() { - return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2); + return (int)Math.round(getMaxEnergy() * Mekanism.TO_IC2); } @Override @@ -389,7 +403,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public double getDemandedEnergy() { - return (getMaxEnergy() - getEnergy())*Mekanism.TO_IC2; + return (getMaxEnergy() - getEnergy()) * Mekanism.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public double getOfferedEnergy() + { + return Math.min(getEnergy(), getMaxOutput()) * Mekanism.TO_IC2; } @Override @@ -402,19 +423,26 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i @Method(modid = "IC2") public double getOutputEnergyUnitsPerTick() { - return getMaxOutput()*Mekanism.TO_IC2; + return getMaxOutput() * Mekanism.TO_IC2; } @Override @Method(modid = "IC2") - public double injectEnergy(ForgeDirection direction, double i, double v) + public double injectEnergy(ForgeDirection direction, double amount, double voltage) { if(Coord4D.get(this).getFromSide(direction).getTileEntity(worldObj) instanceof IGridTransmitter) { - return i; + return amount; } - return i-transferEnergyToAcceptor(direction, i*Mekanism.FROM_IC2)*Mekanism.TO_IC2; + return amount-transferEnergyToAcceptor(direction, amount*Mekanism.FROM_IC2)*Mekanism.TO_IC2; + } + + @Override + @Method(modid = "IC2") + public void drawEnergy(double amount) + { + setEnergy(Math.max(getEnergy() - (amount * Mekanism.FROM_IC2), 0)); } @Override diff --git a/src/main/java/mekanism/generators/common/block/BlockGenerator.java b/src/main/java/mekanism/generators/common/block/BlockGenerator.java index 0a6f9f2ac..7eb817cf4 100644 --- a/src/main/java/mekanism/generators/common/block/BlockGenerator.java +++ b/src/main/java/mekanism/generators/common/block/BlockGenerator.java @@ -493,20 +493,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP return itemStack; } - @Override - public void onBlockAdded(World world, int x, int y, int z) - { - TileEntity tileEntity = world.getTileEntity(x, y, z); - - if(!world.isRemote) - { - if(tileEntity != null && MekanismUtils.useIC2()) - { - ((TileEntityElectricBlock)tileEntity).register(); - } - } - } - @Override public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) {