diff --git a/src/api/java/ic2/api/Direction.java b/src/api/java/ic2/api/Direction.java index 64350dd56..f0c687bbf 100644 --- a/src/api/java/ic2/api/Direction.java +++ b/src/api/java/ic2/api/Direction.java @@ -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(); } diff --git a/src/api/java/ic2/api/energy/IEnergyNet.java b/src/api/java/ic2/api/energy/IEnergyNet.java index 4d07b9838..8f656e505 100644 --- a/src/api/java/ic2/api/energy/IEnergyNet.java +++ b/src/api/java/ic2/api/energy/IEnergyNet.java @@ -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. * diff --git a/src/api/java/ic2/api/energy/NodeStats.java b/src/api/java/ic2/api/energy/NodeStats.java new file mode 100644 index 000000000..db33da7df --- /dev/null +++ b/src/api/java/ic2/api/energy/NodeStats.java @@ -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; +} diff --git a/src/api/java/ic2/api/energy/tile/IEnergySink.java b/src/api/java/ic2/api/energy/tile/IEnergySink.java index 9676bff1b..4ae8e7954 100644 --- a/src/api/java/ic2/api/energy/tile/IEnergySink.java +++ b/src/api/java/ic2/api/energy/tile/IEnergySink.java @@ -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 */ diff --git a/src/api/java/ic2/api/info/IEnergyValueProvider.java b/src/api/java/ic2/api/info/IEnergyValueProvider.java index 178a95431..1e7b2cc57 100644 --- a/src/api/java/ic2/api/info/IEnergyValueProvider.java +++ b/src/api/java/ic2/api/info/IEnergyValueProvider.java @@ -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 */ diff --git a/src/api/java/ic2/api/item/IElectricItemManager.java b/src/api/java/ic2/api/item/IElectricItemManager.java index dfadbb26c..5de43d773 100644 --- a/src/api/java/ic2/api/item/IElectricItemManager.java +++ b/src/api/java/ic2/api/item/IElectricItemManager.java @@ -90,4 +90,6 @@ public interface IElectricItemManager { * @return tool tip string or null for none */ String getToolTip(ItemStack stack); + + // TODO: add tier getter } diff --git a/src/api/java/ic2/api/recipe/RecipeOutput.java b/src/api/java/ic2/api/recipe/RecipeOutput.java index c9474cd71..867cfa258 100644 --- a/src/api/java/ic2/api/recipe/RecipeOutput.java +++ b/src/api/java/ic2/api/recipe/RecipeOutput.java @@ -8,6 +8,8 @@ import net.minecraft.nbt.NBTTagCompound; public final class RecipeOutput { public RecipeOutput(NBTTagCompound metadata1, List 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 items; public final NBTTagCompound metadata; } diff --git a/src/api/java/ic2/api/recipe/Recipes.java b/src/api/java/ic2/api/recipe/Recipes.java index 2ee76fc1b..4c1259768 100644 --- a/src/api/java/ic2/api/recipe/Recipes.java +++ b/src/api/java/ic2/api/recipe/Recipes.java @@ -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; - }