Merge branch 'master' into development
This commit is contained in:
commit
d0a62c564e
20 changed files with 212 additions and 112 deletions
|
@ -12,41 +12,39 @@ public enum Direction {
|
|||
/**
|
||||
* -X
|
||||
*/
|
||||
XN(0),
|
||||
XN,
|
||||
/**
|
||||
* +X
|
||||
*/
|
||||
XP(1),
|
||||
XP,
|
||||
|
||||
/**
|
||||
* -Y
|
||||
*/
|
||||
YN(2), //MC-Code starts with 0 here
|
||||
YN, //MC-Code starts with 0 here
|
||||
/**
|
||||
* +Y
|
||||
*/
|
||||
YP(3), // 1...
|
||||
YP, // 1...
|
||||
|
||||
/**
|
||||
* -Z
|
||||
*/
|
||||
ZN(4),
|
||||
ZN,
|
||||
/**
|
||||
* +Z
|
||||
*/
|
||||
ZP(5);
|
||||
ZP;
|
||||
|
||||
Direction(int dir1) {
|
||||
this.dir = dir1;
|
||||
public static Direction fromSideValue(int side) {
|
||||
return directions[(side + 2) % 6];
|
||||
}
|
||||
|
||||
/*public CoordinateTuple ApplyToCoordinates(CoordinateTuple coordinates) {
|
||||
CoordinateTuple ret = new CoordinateTuple(coordinates);
|
||||
public static Direction fromForgeDirection(ForgeDirection dir) {
|
||||
if (dir == ForgeDirection.UNKNOWN) return null;
|
||||
|
||||
ret.coords[dir/2] += GetSign();
|
||||
|
||||
return ret;
|
||||
}*/
|
||||
return fromSideValue(dir.ordinal());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tile entity next to a tile entity following this direction.
|
||||
|
@ -70,7 +68,7 @@ public enum Direction {
|
|||
public TileEntity applyTo(World world, int x, int y, int z) {
|
||||
int coords[] = { x, y, z };
|
||||
|
||||
coords[dir/2] += getSign();
|
||||
coords[ordinal() / 2] += getSign();
|
||||
|
||||
if (world != null && world.blockExists(coords[0], coords[1], coords[2])) {
|
||||
try {
|
||||
|
@ -89,13 +87,7 @@ public enum Direction {
|
|||
* @return Inverse direction
|
||||
*/
|
||||
public Direction getInverse() {
|
||||
int inverseDir = dir - getSign();
|
||||
|
||||
for (Direction direction : directions) {
|
||||
if (direction.dir == inverseDir) return direction;
|
||||
}
|
||||
|
||||
return this;
|
||||
return directions[ordinal() ^ 1];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -104,7 +96,7 @@ public enum Direction {
|
|||
* @return Minecraft side value
|
||||
*/
|
||||
public int toSideValue() {
|
||||
return (dir + 4) % 6;
|
||||
return (ordinal() + 4) % 6;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -113,14 +105,13 @@ public enum Direction {
|
|||
* @return -1 if the direction is negative, +1 if the direction is positive
|
||||
*/
|
||||
private int getSign() {
|
||||
return (dir % 2) * 2 - 1;
|
||||
return (ordinal() % 2) * 2 - 1;
|
||||
}
|
||||
|
||||
public ForgeDirection toForgeDirection() {
|
||||
return ForgeDirection.getOrientation(toSideValue());
|
||||
}
|
||||
|
||||
private int dir;
|
||||
public static final Direction[] directions = Direction.values();
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,9 @@ public interface IEnergyNet {
|
|||
* @note call this twice with x ticks delay to get the avg. emitted power p = (call2 - call1) / x EU/tick
|
||||
*
|
||||
* @param tileEntity energy emitter
|
||||
* @deprecated Discontinued, use getNodeStats instead.
|
||||
*/
|
||||
@Deprecated
|
||||
double getTotalEnergyEmitted(TileEntity tileEntity);
|
||||
|
||||
/**
|
||||
|
@ -51,9 +53,21 @@ public interface IEnergyNet {
|
|||
* @note call this twice with x ticks delay to get the avg. sunken power p = (call2 - call1) / x EU/tick
|
||||
*
|
||||
* @param tileEntity energy emitter
|
||||
* @deprecated Discontinued, use getNodeStats instead.
|
||||
*/
|
||||
@Deprecated
|
||||
double getTotalEnergySunken(TileEntity tileEntity);
|
||||
|
||||
/**
|
||||
* Retrieve statistics for the tile entity specified.
|
||||
*
|
||||
* The statistics apply to the last simulated tick.
|
||||
*
|
||||
* @param te Tile entity to check.
|
||||
* @return Statistics for the tile entity.
|
||||
*/
|
||||
NodeStats getNodeStats(TileEntity te);
|
||||
|
||||
/**
|
||||
* Determine the typical power used by the specific tier, e.g. 128 eu/t for tier 2.
|
||||
*
|
||||
|
|
25
src/api/java/ic2/api/energy/NodeStats.java
Normal file
25
src/api/java/ic2/api/energy/NodeStats.java
Normal file
|
@ -0,0 +1,25 @@
|
|||
package ic2.api.energy;
|
||||
|
||||
public class NodeStats {
|
||||
public NodeStats(double energyIn, double energyOut, double voltage) {
|
||||
this.energyIn = energyIn;
|
||||
this.energyOut = energyOut;
|
||||
this.voltage = voltage;
|
||||
}
|
||||
|
||||
public double getEnergyIn() {
|
||||
return energyIn;
|
||||
}
|
||||
|
||||
public double getEnergyOut() {
|
||||
return energyOut;
|
||||
}
|
||||
|
||||
public double getVoltage() {
|
||||
return voltage;
|
||||
}
|
||||
|
||||
protected double energyIn;
|
||||
protected double energyOut;
|
||||
protected double voltage;
|
||||
}
|
53
src/api/java/ic2/api/energy/tile/IEnergyConductor.java
Normal file
53
src/api/java/ic2/api/energy/tile/IEnergyConductor.java
Normal file
|
@ -0,0 +1,53 @@
|
|||
package ic2.api.energy.tile;
|
||||
|
||||
/**
|
||||
* Tile entities which conduct energy pulses without buffering (mostly cables) have to implement this
|
||||
* interface.
|
||||
*
|
||||
* See ic2/api/energy/usage.txt for an overall description of the energy net api.
|
||||
*/
|
||||
public interface IEnergyConductor extends IEnergyAcceptor, IEnergyEmitter {
|
||||
/**
|
||||
* Energy loss for the conductor in EU per block.
|
||||
*
|
||||
* @return Energy loss
|
||||
*/
|
||||
double getConductionLoss();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before shocking nearby players and mobs.
|
||||
*
|
||||
* @return Insulation energy absorption in EU
|
||||
*/
|
||||
double getInsulationEnergyAbsorption();
|
||||
|
||||
/**
|
||||
* Amount of energy the insulation will handle before it is destroyed.
|
||||
* Ensure that this value is greater than the insulation energy absorption + 64.
|
||||
*
|
||||
* @return Insulation-destroying energy in EU
|
||||
*/
|
||||
double getInsulationBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Amount of energy the conductor will handle before it melts.
|
||||
*
|
||||
* @return Conductor-destroying energy in EU
|
||||
*/
|
||||
double getConductorBreakdownEnergy();
|
||||
|
||||
/**
|
||||
* Remove the conductor's insulation if the insulation breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getInsulationBreakdownEnergy()
|
||||
*/
|
||||
void removeInsulation();
|
||||
|
||||
/**
|
||||
* Remove the conductor if the conductor breakdown energy was exceeded.
|
||||
*
|
||||
* @see #getConductorBreakdownEnergy()
|
||||
*/
|
||||
void removeConductor();
|
||||
}
|
||||
|
|
@ -24,6 +24,7 @@ public interface IEnergySink extends IEnergyAcceptor {
|
|||
* 1 = LV, 2 = MV, 3 = HV, 4 = EV etc.
|
||||
*
|
||||
* @note Modifying the energy net from this method is disallowed.
|
||||
* @note Return Integer.MAX_VALUE to allow any voltage.
|
||||
*
|
||||
* @return tier of this energy sink
|
||||
*/
|
||||
|
|
|
@ -7,6 +7,9 @@ public interface IEnergyValueProvider {
|
|||
* Determine the energy value for a single item in the supplied stack.
|
||||
* The value is used by most machines in the discharge slot.
|
||||
*
|
||||
* This only applies to basic single use items, others are to be queried
|
||||
* through e.g. ElectricItem.manager.getCharge().
|
||||
*
|
||||
* @param itemStack ItemStack containing the item to evaluate.
|
||||
* @return energy in EU
|
||||
*/
|
||||
|
|
|
@ -90,4 +90,6 @@ public interface IElectricItemManager {
|
|||
* @return tool tip string or null for none
|
||||
*/
|
||||
String getToolTip(ItemStack stack);
|
||||
|
||||
// TODO: add tier getter
|
||||
}
|
||||
|
|
|
@ -8,6 +8,8 @@ import net.minecraft.nbt.NBTTagCompound;
|
|||
|
||||
public final class RecipeOutput {
|
||||
public RecipeOutput(NBTTagCompound metadata1, List<ItemStack> items1) {
|
||||
assert !items1.contains(null);
|
||||
|
||||
this.metadata = metadata1;
|
||||
this.items = items1;
|
||||
}
|
||||
|
@ -16,6 +18,11 @@ public final class RecipeOutput {
|
|||
this(metadata1, Arrays.asList(items1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ROutput<"+items+","+metadata+">";
|
||||
}
|
||||
|
||||
public final List<ItemStack> items;
|
||||
public final NBTTagCompound metadata;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ic2.api.recipe;
|
||||
|
||||
|
||||
/**
|
||||
* General recipe registry.
|
||||
*
|
||||
|
@ -10,6 +11,8 @@ public class Recipes {
|
|||
public static IMachineRecipeManager extractor;
|
||||
public static IMachineRecipeManager compressor;
|
||||
public static IMachineRecipeManager centrifuge;
|
||||
public static IMachineRecipeManager blockcutter;
|
||||
public static IMachineRecipeManager blastfurance;
|
||||
public static IMachineRecipeManager recycler;
|
||||
public static IMachineRecipeManager metalformerExtruding;
|
||||
public static IMachineRecipeManager metalformerCutting;
|
||||
|
@ -54,5 +57,4 @@ public class Recipes {
|
|||
|
||||
public static ISemiFluidFuelManager semiFluidGenerator;
|
||||
public static IFluidHeatManager FluidHeatGenerator;
|
||||
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
|||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||
})
|
||||
|
|
|
@ -228,8 +228,6 @@ public class Mekanism
|
|||
public static Set<String> jetpackOn = new HashSet<String>();
|
||||
public static Set<String> gasmaskOn = new HashSet<String>();
|
||||
|
||||
public static Set<Coord4D> ic2Registered = new HashSet<Coord4D>();
|
||||
|
||||
public static Set<Coord4D> activeVibrators = new HashSet<Coord4D>();
|
||||
|
||||
//Items
|
||||
|
@ -1286,7 +1284,6 @@ public class Mekanism
|
|||
//Clear all cache data
|
||||
teleporters.clear();
|
||||
dynamicInventories.clear();
|
||||
ic2Registered.clear();
|
||||
jetpackOn.clear();
|
||||
gasmaskOn.clear();
|
||||
activeVibrators.clear();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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<IRecipeInput, RecipeOutput> entry : Recipes.macerator.getRecipes().entrySet())
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -20,7 +20,7 @@ public class ItemElectricBow extends ItemEnergized
|
|||
public ItemElectricBow()
|
||||
{
|
||||
super(120000);
|
||||
this.setFull3D;
|
||||
setFull3D();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -27,7 +27,7 @@ import dan200.computercraft.api.peripheral.IPeripheral;
|
|||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "buildcraft.api.power.IPowerReceptor", modid = "BuildCraftAPI|power"),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||
@Interface(iface = "dan200.computercraft.api.peripheral.IPeripheral", modid = "ComputerCraft")
|
||||
})
|
||||
|
@ -194,7 +194,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
if(getInv() == null)
|
||||
|
@ -357,7 +357,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public double getDemandedEnergy()
|
||||
{
|
||||
if(getInv() == null)
|
||||
|
@ -369,7 +369,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public double injectEnergy(ForgeDirection directionFrom, double amount, double voltage)
|
||||
{
|
||||
if(getInv() == null)
|
||||
|
@ -381,7 +381,7 @@ public class TileEntityAdvancedBoundingBlock extends TileEntityBoundingBlock imp
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int getSinkTier()
|
||||
{
|
||||
if(getInv() == null)
|
||||
|
|
|
@ -1,8 +1,12 @@
|
|||
package mekanism.common.tile;
|
||||
|
||||
import ic2.api.energy.EnergyNet;
|
||||
import ic2.api.energy.event.EnergyTileLoadEvent;
|
||||
import ic2.api.energy.event.EnergyTileUnloadEvent;
|
||||
import ic2.api.energy.tile.IEnergyConductor;
|
||||
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;
|
||||
|
||||
|
@ -33,13 +37,13 @@ import buildcraft.api.power.PowerHandler.PowerReceiver;
|
|||
import cofh.api.energy.IEnergyHandler;
|
||||
|
||||
@InterfaceList({
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2API", striprefs = true),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2API", striprefs = true),
|
||||
@Interface(iface = "ic2.api.energy.tile.IEnergySink", modid = "IC2"),
|
||||
@Interface(iface = "ic2.api.tile.IEnergyStorage", modid = "IC2"),
|
||||
@Interface(iface = "cofh.api.energy.IEnergyHandler", modid = "CoFHAPI|energy"),
|
||||
@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;
|
||||
|
@ -50,6 +54,9 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
/** BuildCraft power handler. */
|
||||
public PowerHandler powerHandler;
|
||||
|
||||
/** Is this registered with IC2 */
|
||||
public boolean ic2Registered = false;
|
||||
|
||||
/**
|
||||
* The base of all blocks that deal with electricity. It has a facing state, initialized state,
|
||||
* and a current amount of stored energy.
|
||||
|
@ -74,28 +81,36 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
}
|
||||
|
||||
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public void register()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(!Mekanism.ic2Registered.contains(Coord4D.get(this)))
|
||||
TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord);
|
||||
if(registered != this)
|
||||
{
|
||||
Mekanism.ic2Registered.add(Coord4D.get(this));
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
if(registered instanceof IEnergyTile)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered));
|
||||
}
|
||||
else if(registered == null)
|
||||
{
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileLoadEvent(this));
|
||||
ic2Registered = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public void deregister()
|
||||
{
|
||||
if(!worldObj.isRemote)
|
||||
{
|
||||
if(Mekanism.ic2Registered.contains(Coord4D.get(this)))
|
||||
TileEntity registered = EnergyNet.instance.getTileEntity(worldObj, xCoord, yCoord, zCoord);
|
||||
if(registered instanceof IEnergyTile)
|
||||
{
|
||||
Mekanism.ic2Registered.remove(Coord4D.get(this));
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent(this));
|
||||
MinecraftForge.EVENT_BUS.post(new EnergyTileUnloadEvent((IEnergyTile)registered));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -105,6 +120,8 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
{
|
||||
if(MekanismUtils.useBuildCraft())
|
||||
reconfigure();
|
||||
if(!ic2Registered && MekanismUtils.useIC2())
|
||||
register();
|
||||
}
|
||||
|
||||
public EnumSet<ForgeDirection> getOutputtingSides()
|
||||
|
@ -210,7 +227,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
|
||||
|
@ -307,21 +324,28 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int getSinkTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int getSourceTier()
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2")
|
||||
public void setStored(int energy)
|
||||
{
|
||||
setEnergy(energy*Mekanism.FROM_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int addEnergy(int amount)
|
||||
{
|
||||
setEnergy(getEnergy() + amount*Mekanism.FROM_IC2);
|
||||
|
@ -329,7 +353,7 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public boolean isTeleporterCompatible(ForgeDirection side)
|
||||
{
|
||||
return getOutputtingSides().contains(side);
|
||||
|
@ -342,38 +366,52 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public boolean acceptsEnergyFrom(TileEntity emitter, ForgeDirection direction)
|
||||
{
|
||||
return !getOutputtingSides().contains(direction);
|
||||
return getConsumingSides().contains(direction);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public boolean emitsEnergyTo(TileEntity receiver, ForgeDirection direction)
|
||||
{
|
||||
return getOutputtingSides().contains(direction) && receiver instanceof IEnergyConductor;
|
||||
}
|
||||
|
||||
@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 = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int getCapacity()
|
||||
{
|
||||
return (int)Math.round(getMaxEnergy()*Mekanism.TO_IC2);
|
||||
return (int)Math.round(getMaxEnergy() * Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public int getOutput()
|
||||
{
|
||||
return (int)Math.round(getMaxOutput()*Mekanism.TO_IC2);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@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
|
||||
|
@ -383,22 +421,29 @@ public abstract class TileEntityElectricBlock extends TileEntityContainerBlock i
|
|||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
@Method(modid = "IC2")
|
||||
public double getOutputEnergyUnitsPerTick()
|
||||
{
|
||||
return getMaxOutput()*Mekanism.TO_IC2;
|
||||
return getMaxOutput() * Mekanism.TO_IC2;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Method(modid = "IC2API")
|
||||
public double injectEnergy(ForgeDirection direction, double i, double v)
|
||||
@Method(modid = "IC2")
|
||||
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
|
||||
|
|
|
@ -76,6 +76,7 @@ import cpw.mods.fml.common.ModContainer;
|
|||
import cpw.mods.fml.common.registry.GameData;
|
||||
|
||||
import buildcraft.api.tools.IToolWrench;
|
||||
import ic2.api.energy.EnergyNet;
|
||||
|
||||
/**
|
||||
* Utilities used by Mekanism. All miscellaneous methods are located here.
|
||||
|
@ -1208,7 +1209,7 @@ public final class MekanismUtils
|
|||
*/
|
||||
public static boolean useIC2()
|
||||
{
|
||||
return Mekanism.hooks.IC2Loaded && !Mekanism.blacklistIC2;
|
||||
return Mekanism.hooks.IC2Loaded && EnergyNet.instance != null && !Mekanism.blacklistIC2;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue