Update IC2 api

This commit is contained in:
Ben Spiers 2014-10-02 18:03:22 +01:00
parent 3c715d906b
commit 3e71622d95
8 changed files with 71 additions and 26 deletions

View file

@ -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();
}

View file

@ -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.
*

View 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;
}

View file

@ -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
*/

View file

@ -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
*/

View file

@ -90,4 +90,6 @@ public interface IElectricItemManager {
* @return tool tip string or null for none
*/
String getToolTip(ItemStack stack);
// TODO: add tier getter
}

View file

@ -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;
}

View file

@ -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;
}