ElectricBlocks now output to IC2 properly.

This commit is contained in:
Ben Spiers 2014-10-02 18:13:19 +01:00
parent 3e71622d95
commit f0b7f342b8
6 changed files with 42 additions and 55 deletions

View file

@ -251,17 +251,6 @@ public class BlockEnergyCube extends BlockContainer implements IPeripheralProvid
return itemStack; 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) public ItemStack dismantleBlock(World world, int x, int y, int z, boolean returnBlock)
{ {
ItemStack itemStack = getPickBlock(null, world, x, y, z); ItemStack itemStack = getPickBlock(null, world, x, y, z);

View file

@ -1124,20 +1124,6 @@ public class BlockMachine extends BlockContainer implements ISpecialBounds, IPer
return true; 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 public static enum MachineType
{ {
ENRICHMENT_CHAMBER(Mekanism.MachineBlock, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, true, false, true), ENRICHMENT_CHAMBER(Mekanism.MachineBlock, 0, "EnrichmentChamber", 3, Mekanism.enrichmentChamberUsage*400, TileEntityEnrichmentChamber.class, true, false, true),

View file

@ -30,8 +30,6 @@ import ic2.api.recipe.Recipes;
*/ */
public final class MekanismHooks public final class MekanismHooks
{ {
private Class BasicComponents;
private Class BuildCraftEnergy; private Class BuildCraftEnergy;
public boolean IC2Loaded = false; public boolean IC2Loaded = false;
@ -80,7 +78,7 @@ public final class MekanismHooks
} }
@Method(modid = "IC2API") @Method(modid = "IC2")
public void hookIC2Recipes() public void hookIC2Recipes()
{ {
for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet()) for(Map.Entry<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())

View file

@ -398,7 +398,7 @@ public final class OreDictManager
try { try {
RecipeHandler.addCrusherRecipe(new ItemStack(Mekanism.Ingot, 1, 2), MekanismUtils.size(OreDictionary.getOres("dustBronze").get(0), 1)); 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(); addIC2BronzeRecipe();
} }
@ -506,7 +506,7 @@ public final class OreDictManager
} }
@Method(modid = "IC2API") @Method(modid = "IC2")
public static void addIC2BronzeRecipe() public static void addIC2BronzeRecipe()
{ {
try { try {

View file

@ -4,6 +4,7 @@ import ic2.api.energy.EnergyNet;
import ic2.api.energy.event.EnergyTileLoadEvent; import ic2.api.energy.event.EnergyTileLoadEvent;
import ic2.api.energy.event.EnergyTileUnloadEvent; import ic2.api.energy.event.EnergyTileUnloadEvent;
import ic2.api.energy.tile.IEnergySink; import ic2.api.energy.tile.IEnergySink;
import ic2.api.energy.tile.IEnergySource;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IEnergyStorage; import ic2.api.tile.IEnergyStorage;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
@ -16,7 +17,6 @@ import mekanism.api.energy.ICableOutputter;
import mekanism.api.energy.IStrictEnergyAcceptor; import mekanism.api.energy.IStrictEnergyAcceptor;
import mekanism.api.energy.IStrictEnergyStorage; import mekanism.api.energy.IStrictEnergyStorage;
import mekanism.api.transmitters.IGridTransmitter; import mekanism.api.transmitters.IGridTransmitter;
import mekanism.common.EnergyNetwork.EnergyTransferEvent;
import mekanism.common.ITileNetwork; import mekanism.common.ITileNetwork;
import mekanism.common.Mekanism; import mekanism.common.Mekanism;
import mekanism.common.util.MekanismUtils; 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.IPowerReceptor", modid = "BuildCraftAPI|power"),
@Interface(iface = "buildcraft.api.power.IPowerEmitter", 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. */ /** How much energy is stored in this block. */
public double electricityStored; public double electricityStored;
@ -226,7 +226,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Method(modid = "BuildCraftAPI|power") @Method(modid = "BuildCraftAPI|power")
protected void reconfigure() 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 @Override
@ -329,6 +329,13 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
return 4; return 4;
} }
@Override
@Method(modid = "IC2")
public int getSourceTier()
{
return 4;
}
@Override @Override
@Method(modid = "IC2") @Method(modid = "IC2")
public void setStored(int energy) public void setStored(int energy)
@ -361,21 +368,28 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Method(modid = "IC2") @Method(modid = "IC2")
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction) 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 @Override
@Method(modid = "IC2") @Method(modid = "IC2")
public int getStored() public int getStored()
{ {
return (int)Math.round(getEnergy()*Mekanism.TO_IC2); return (int)Math.round(getEnergy() * Mekanism.TO_IC2);
} }
@Override @Override
@Method(modid = "IC2") @Method(modid = "IC2")
public int getCapacity() public int getCapacity()
{ {
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2); return (int)Math.round(getMaxEnergy() * Mekanism.TO_IC2);
} }
@Override @Override
@ -389,7 +403,14 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Method(modid = "IC2") @Method(modid = "IC2")
public double getDemandedEnergy() 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 @Override
@ -402,19 +423,26 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
@Method(modid = "IC2") @Method(modid = "IC2")
public double getOutputEnergyUnitsPerTick() public double getOutputEnergyUnitsPerTick()
{ {
return getMaxOutput()*Mekanism.TO_IC2; return getMaxOutput() * Mekanism.TO_IC2;
} }
@Override @Override
@Method(modid = "IC2") @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) 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 @Override

View file

@ -493,20 +493,6 @@ public class BlockGenerator extends BlockContainer implements ISpecialBounds, IP
return itemStack; 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 @Override
public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side) public boolean isSideSolid(IBlockAccess world, int x, int y, int z, ForgeDirection side)
{ {