Updated UE API

This commit is contained in:
Calclavia 2013-12-01 14:41:01 +08:00
parent e967becb5c
commit f17982f85d
18 changed files with 862 additions and 887 deletions

View file

@ -11,7 +11,8 @@ package buildcraft.api.core;
import net.minecraft.block.Block;
public class BuildCraftAPI {
public class BuildCraftAPI
{
public static final int LAST_ORIGINAL_BLOCK = 122;
public static final int LAST_ORIGINAL_ITEM = 126;

View file

@ -10,9 +10,11 @@
package buildcraft.api.core;
/**
* To be implemented by TileEntities able to provide a square area on the world, typically BuildCraft markers.
* To be implemented by TileEntities able to provide a square area on the world, typically
* BuildCraft markers.
*/
public interface IAreaProvider {
public interface IAreaProvider
{
public int xMin();

View file

@ -11,7 +11,8 @@ package buildcraft.api.core;
import net.minecraft.world.World;
public interface IBox {
public interface IBox
{
public void expand(int amount);

View file

@ -1,12 +1,13 @@
package buildcraft.api.core;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.util.Icon;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
public interface IIconProvider
{
public interface IIconProvider {
/**
* @param iconIndex
* @return
@ -15,7 +16,9 @@ public interface IIconProvider {
public Icon getIcon(int iconIndex);
/**
* A call for the provider to register its Icons. This may be called multiple times but should only be executed once per provider
* A call for the provider to register its Icons. This may be called multiple times but should
* only be executed once per provider
*
* @param iconRegister
*/
@SideOnly(Side.CLIENT)

View file

@ -9,6 +9,7 @@
package buildcraft.api.core;
public enum LaserKind {
public enum LaserKind
{
Red, Blue, Stripes
}

View file

@ -13,33 +13,38 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class Position {
public class Position
{
public double x, y, z;
public ForgeDirection orientation;
public Position(double ci, double cj, double ck) {
public Position(double ci, double cj, double ck)
{
x = ci;
y = cj;
z = ck;
orientation = ForgeDirection.UNKNOWN;
}
public Position(double ci, double cj, double ck, ForgeDirection corientation) {
public Position(double ci, double cj, double ck, ForgeDirection corientation)
{
x = ci;
y = cj;
z = ck;
orientation = corientation;
}
public Position(Position p) {
public Position(Position p)
{
x = p.x;
y = p.y;
z = p.z;
orientation = p.orientation;
}
public Position(NBTTagCompound nbttagcompound) {
public Position(NBTTagCompound nbttagcompound)
{
x = nbttagcompound.getDouble("i");
y = nbttagcompound.getDouble("j");
z = nbttagcompound.getDouble("k");
@ -47,95 +52,109 @@ public class Position {
orientation = ForgeDirection.UNKNOWN;
}
public Position(TileEntity tile) {
public Position(TileEntity tile)
{
x = tile.xCoord;
y = tile.yCoord;
z = tile.zCoord;
}
public void moveRight(double step) {
switch (orientation) {
case SOUTH:
x = x - step;
break;
case NORTH:
x = x + step;
break;
case EAST:
z = z + step;
break;
case WEST:
z = z - step;
break;
default:
public void moveRight(double step)
{
switch (orientation)
{
case SOUTH:
x = x - step;
break;
case NORTH:
x = x + step;
break;
case EAST:
z = z + step;
break;
case WEST:
z = z - step;
break;
default:
}
}
public void moveLeft(double step) {
public void moveLeft(double step)
{
moveRight(-step);
}
public void moveForwards(double step) {
switch (orientation) {
case UP:
y = y + step;
break;
case DOWN:
y = y - step;
break;
case SOUTH:
z = z + step;
break;
case NORTH:
z = z - step;
break;
case EAST:
x = x + step;
break;
case WEST:
x = x - step;
break;
default:
public void moveForwards(double step)
{
switch (orientation)
{
case UP:
y = y + step;
break;
case DOWN:
y = y - step;
break;
case SOUTH:
z = z + step;
break;
case NORTH:
z = z - step;
break;
case EAST:
x = x + step;
break;
case WEST:
x = x - step;
break;
default:
}
}
public void moveBackwards(double step) {
public void moveBackwards(double step)
{
moveForwards(-step);
}
public void moveUp(double step) {
switch (orientation) {
case SOUTH:
case NORTH:
case EAST:
case WEST:
y = y + step;
break;
default:
public void moveUp(double step)
{
switch (orientation)
{
case SOUTH:
case NORTH:
case EAST:
case WEST:
y = y + step;
break;
default:
}
}
public void moveDown(double step) {
public void moveDown(double step)
{
moveUp(-step);
}
public void writeToNBT(NBTTagCompound nbttagcompound) {
public void writeToNBT(NBTTagCompound nbttagcompound)
{
nbttagcompound.setDouble("i", x);
nbttagcompound.setDouble("j", y);
nbttagcompound.setDouble("k", z);
}
@Override
public String toString() {
public String toString()
{
return "{" + x + ", " + y + ", " + z + "}";
}
public Position min(Position p) {
public Position min(Position p)
{
return new Position(p.x > x ? x : p.x, p.y > y ? y : p.y, p.z > z ? z : p.z);
}
public Position max(Position p) {
public Position max(Position p)
{
return new Position(p.x < x ? x : p.x, p.y < y ? y : p.y, p.z < z ? z : p.z);
}

View file

@ -9,38 +9,45 @@ package buildcraft.api.core;
import net.minecraft.world.World;
public class SafeTimeTracker {
public class SafeTimeTracker
{
private long lastMark = Long.MIN_VALUE;
private long duration = -1;
/**
* Return true if a given delay has passed since last time marked was called
* successfully.
* Return true if a given delay has passed since last time marked was called successfully.
*/
public boolean markTimeIfDelay(World world, long delay) {
public boolean markTimeIfDelay(World world, long delay)
{
if (world == null)
return false;
long currentTime = world.getTotalWorldTime();
if (currentTime < lastMark) {
if (currentTime < lastMark)
{
lastMark = currentTime;
return false;
} else if (lastMark + delay <= currentTime) {
}
else if (lastMark + delay <= currentTime)
{
duration = currentTime - lastMark;
lastMark = currentTime;
return true;
} else
}
else
return false;
}
public long durationOfLastDelay() {
public long durationOfLastDelay()
{
return duration > 0 ? duration : 0;
}
public void markTime(World world) {
public void markTime(World world)
{
lastMark = world.getTotalWorldTime();
}
}

View file

@ -11,19 +11,22 @@ package buildcraft.api.core;
import net.minecraft.item.ItemStack;
/**
*
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public class StackWrapper {
public class StackWrapper
{
public final ItemStack stack;
public StackWrapper(ItemStack stack) {
public StackWrapper(ItemStack stack)
{
this.stack = stack;
}
@Override
public int hashCode() {
public int hashCode()
{
int hash = 5;
hash = 67 * hash + stack.itemID;
hash = 67 * hash + stack.getItemDamage();
@ -33,7 +36,8 @@ public class StackWrapper {
}
@Override
public boolean equals(Object obj) {
public boolean equals(Object obj)
{
if (obj == null)
return false;
if (getClass() != obj.getClass())

View file

@ -12,13 +12,14 @@ import net.minecraftforge.common.ForgeDirection;
/**
* Essentially only used for Wooden Power Pipe connection rules.
*
* This Tile Entity interface allows you to indicate that a block can emit power
* from a specific side.
*
*
* This Tile Entity interface allows you to indicate that a block can emit power from a specific
* side.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerEmitter {
public interface IPowerEmitter
{
public boolean canEmitPowerFrom(ForgeDirection side);
}

View file

@ -7,38 +7,37 @@
*/
package buildcraft.api.power;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.power.PowerHandler.PowerReceiver;
/**
* This interface should be implemented by any Tile Entity that wishes to be
* able to receive power.
*
* This interface should be implemented by any Tile Entity that wishes to be able to receive power.
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public interface IPowerReceptor {
public interface IPowerReceptor
{
/**
* Get the PowerReceiver for this side of the block. You can return the same
* PowerReceiver for all sides or one for each side.
*
* You should NOT return null to this method unless you mean to NEVER
* receive power from that side. Returning null, after previous returning a
* PowerReceiver, will most likely cause pipe connections to derp out and
* engines to eventually explode.
*
* Get the PowerReceiver for this side of the block. You can return the same PowerReceiver for
* all sides or one for each side.
*
* You should NOT return null to this method unless you mean to NEVER receive power from that
* side. Returning null, after previous returning a PowerReceiver, will most likely cause pipe
* connections to derp out and engines to eventually explode.
*
* @param side
* @return
*/
public PowerReceiver getPowerReceiver(ForgeDirection side);
/**
* Call back from the PowerHandler that is called when the stored power
* exceeds the activation power.
*
* Call back from the PowerHandler that is called when the stored power exceeds the activation
* power.
*
* It can be triggered by update() calls or power modification calls.
*
*
* @param workProvider
*/
public void doWork(PowerHandler workProvider);

View file

@ -7,36 +7,22 @@
*/
package buildcraft.api.power;
import buildcraft.api.core.SafeTimeTracker;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.ForgeDirection;
import buildcraft.api.core.SafeTimeTracker;
/**
* The PowerHandler is similar to FluidTank in that it holds your power and
* allows standardized interaction between machines.
*
* To receive power to your machine you needs create an instance of PowerHandler
* and implement IPowerReceptor on the TileEntity.
*
* If you plan emit power, you need only implement IPowerEmitter. You do not
* need a PowerHandler. Engines have a PowerHandler because they can also
* receive power from other Engines.
*
* See TileRefinery for a simple example of a power using machine.
*
* @see IPowerReceptor
* @see IPowerEmitter
*
* @author CovertJaguar <http://www.railcraft.info/>
*/
public final class PowerHandler {
public final class PowerHandler
{
public static enum Type {
public static enum Type
{
ENGINE, GATE, MACHINE, PIPE, STORAGE;
public boolean canReceiveFromPipes() {
switch (this) {
public boolean canReceiveFromPipes()
{
switch (this)
{
case MACHINE:
case STORAGE:
return true;
@ -45,8 +31,10 @@ public final class PowerHandler {
}
}
public boolean eatsEngineExcess() {
switch (this) {
public boolean eatsEngineExcess()
{
switch (this)
{
case MACHINE:
case STORAGE:
return true;
@ -56,64 +44,48 @@ public final class PowerHandler {
}
}
/**
* Extend this class to create custom Perdition algorithms (its not final).
*
* NOTE: It is not possible to create a Zero perdition algorithm.
*/
public static class PerditionCalculator {
public static class PerditionCalculator
{
public static final float DEFAULT_POWERLOSS = 1F;
public static final float MIN_POWERLOSS = 0.01F;
private final float powerLoss;
public PerditionCalculator() {
public PerditionCalculator()
{
powerLoss = DEFAULT_POWERLOSS;
}
/**
* Simple constructor for simple Perdition per tick.
*
* @param powerLoss power loss per tick
*/
public PerditionCalculator(float powerLoss) {
if (powerLoss < MIN_POWERLOSS) {
public PerditionCalculator(float powerLoss)
{
if (powerLoss < MIN_POWERLOSS)
{
powerLoss = MIN_POWERLOSS;
}
this.powerLoss = powerLoss;
}
/**
* Apply the perdition algorithm to the current stored energy. This
* function can only be called once per tick, but it might not be called
* every tick. It is triggered by any manipulation of the stored energy.
*
* Apply the perdition algorithm to the current stored energy. This function can only be
* called once per tick, but it might not be called every tick. It is triggered by any
* manipulation of the stored energy.
*
* @param powerHandler the PowerHandler requesting the perdition update
* @param current the current stored energy
* @param ticksPassed ticks since the last time this function was called
* @return
*/
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed) {
// float prev = current;
public float applyPerdition(PowerHandler powerHandler, float current, long ticksPassed)
{
current -= powerLoss * ticksPassed;
if (current < 0) {
if (current < 0)
{
current = 0;
}
// powerHandler.totalLostPower += prev - current;
return current;
}
/**
* Taxes a flat rate on all incoming power.
*
* Defaults to 0% tax rate.
*
* @return percent of input to tax
*/
public float getTaxPercent() {
return 0;
}
}
public static final PerditionCalculator DEFAULT_PERDITION = new PerditionCalculator();
private float minEnergyReceived;
private float maxEnergyReceived;
@ -128,63 +100,65 @@ public final class PowerHandler {
private PerditionCalculator perdition;
private final PowerReceiver receiver;
private final Type type;
// Debug
// private double totalLostPower = 0;
// private double totalReceivedPower = 0;
// private double totalUsedPower = 0;
// private long startTime = -1;
public PowerHandler(IPowerReceptor receptor, Type type) {
public PowerHandler(IPowerReceptor receptor, Type type)
{
this.receptor = receptor;
this.type = type;
this.receiver = new PowerReceiver();
this.perdition = DEFAULT_PERDITION;
}
public PowerReceiver getPowerReceiver() {
public PowerReceiver getPowerReceiver()
{
return receiver;
}
public float getMinEnergyReceived() {
public float getMinEnergyReceived()
{
return minEnergyReceived;
}
public float getMaxEnergyReceived() {
public float getMaxEnergyReceived()
{
return maxEnergyReceived;
}
public float getMaxEnergyStored() {
public float getMaxEnergyStored()
{
return maxEnergyStored;
}
public float getActivationEnergy() {
public float getActivationEnergy()
{
return activationEnergy;
}
public float getEnergyStored() {
public float getEnergyStored()
{
return energyStored;
}
/**
* Setup your PowerHandler's settings.
*
* @param minEnergyReceived This is the minimum about of power that will be
* accepted by the PowerHandler. This should generally be greater than the
* activationEnergy if you plan to use the doWork() callback. Anything
* greater than 1 will prevent Redstone Engines from powering this Provider.
* @param maxEnergyReceived The maximum amount of power accepted by the
* PowerHandler. This should generally be less than 500. Too low and larger
* engines will overheat while trying to power the machine. Too high, and
* the engines will never warm up. Greater values also place greater strain
* on the power net.
* @param activationEnergy If the stored energy is greater than this value,
* the doWork() callback is called (once per tick).
* @param maxStoredEnergy The maximum amount of power this PowerHandler can
* store. Values tend to range between 100 and 5000. With 1000 and 1500
* being common.
*
* @param minEnergyReceived This is the minimum about of power that will be accepted by the
* PowerHandler. This should generally be greater than the activationEnergy if you plan to use
* the doWork() callback. Anything greater than 1 will prevent Redstone Engines from powering
* this Provider.
* @param maxEnergyReceived The maximum amount of power accepted by the PowerHandler. This
* should generally be less than 500. Too low and larger engines will overheat while trying to
* power the machine. Too high, and the engines will never warm up. Greater values also place
* greater strain on the power net.
* @param activationEnergy If the stored energy is greater than this value, the doWork()
* callback is called (once per tick).
* @param maxStoredEnergy The maximum amount of power this PowerHandler can store. Values tend
* to range between 100 and 5000. With 1000 and 1500 being common.
*/
public void configure(float minEnergyReceived, float maxEnergyReceived, float activationEnergy, float maxStoredEnergy) {
if (minEnergyReceived > maxEnergyReceived) {
public void configure(float minEnergyReceived, float maxEnergyReceived, float activationEnergy, float maxStoredEnergy)
{
if (minEnergyReceived > maxEnergyReceived)
{
maxEnergyReceived = minEnergyReceived;
}
this.minEnergyReceived = minEnergyReceived;
@ -193,18 +167,10 @@ public final class PowerHandler {
this.activationEnergy = activationEnergy;
}
/**
* Allows you define perdition in terms of loss/ticks.
*
* This function is mostly for legacy implementations. See
* PerditionCalculator for more complex perdition formulas.
*
* @param powerLoss
* @param powerLossRegularity
* @see PerditionCalculator
*/
public void configurePowerPerdition(int powerLoss, int powerLossRegularity) {
if (powerLoss == 0 || powerLossRegularity == 0) {
public void configurePowerPerdition(int powerLoss, int powerLossRegularity)
{
if (powerLoss == 0 || powerLossRegularity == 0)
{
perdition = new PerditionCalculator(0);
return;
}
@ -212,50 +178,44 @@ public final class PowerHandler {
}
/**
* Allows you to define a new PerditionCalculator class to handler perdition
* calculations.
*
* For example if you want exponentially increasing loss based on amount
* stored.
*
* Allows you to define a new PerditionCalculator class to handler perdition calculations.
*
* For example if you want exponentially increasing loss based on amount stored.
*
* @param perdition
*/
public void setPerdition(PerditionCalculator perdition) {
public void setPerdition(PerditionCalculator perdition)
{
if (perdition == null)
perdition = DEFAULT_PERDITION;
this.perdition = perdition;
}
public PerditionCalculator getPerdition() {
public PerditionCalculator getPerdition()
{
if (perdition == null)
return DEFAULT_PERDITION;
return perdition;
}
/**
* Ticks the power handler. You should call this if you can, but its not
* required.
*
* If you don't call it, the possibility exists for some weirdness with the
* perdition algorithm and work callback as its possible they will not be
* called on every tick they otherwise would be. You should be able to
* design around this though if you are aware of the limitations.
* Ticks the power handler. You should call this if you can, but its not required.
*
* If you don't call it, the possibility exists for some weirdness with the perdition algorithm
* and work callback as its possible they will not be called on every tick they otherwise would
* be. You should be able to design around this though if you are aware of the limitations.
*/
public void update() {
// if (startTime == -1)
// startTime = receptor.getWorld().getTotalWorldTime();
// else {
// long duration = receptor.getWorld().getTotalWorldTime() - startTime;
// System.out.printf("Power Stats: %s - Stored: %.2f Gained: %.2f - %.2f/t Lost: %.2f - %.2f/t Used: %.2f - %.2f/t%n", receptor.getClass().getSimpleName(), energyStored, totalReceivedPower, totalReceivedPower / duration, totalLostPower, totalLostPower / duration, totalUsedPower, totalUsedPower / duration);
// }
public void update()
{
applyPerdition();
applyWork();
validateEnergy();
}
private void applyPerdition() {
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0) {
private void applyPerdition()
{
if (perditionTracker.markTimeIfDelay(receptor.getWorld(), 1) && energyStored > 0)
{
float newEnergy = getPerdition().applyPerdition(this, energyStored, perditionTracker.durationOfLastDelay());
if (newEnergy == 0 || newEnergy < energyStored)
energyStored = newEnergy;
@ -265,19 +225,26 @@ public final class PowerHandler {
}
}
private void applyWork() {
if (energyStored >= activationEnergy) {
if (doWorkTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
private void applyWork()
{
if (energyStored >= activationEnergy)
{
if (doWorkTracker.markTimeIfDelay(receptor.getWorld(), 1))
{
receptor.doWork(this);
}
}
}
private void updateSources(ForgeDirection source) {
if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1)) {
for (int i = 0; i < 6; ++i) {
private void updateSources(ForgeDirection source)
{
if (sourcesTracker.markTimeIfDelay(receptor.getWorld(), 1))
{
for (int i = 0; i < 6; ++i)
{
powerSources[i] -= sourcesTracker.durationOfLastDelay();
if (powerSources[i] < 0) {
if (powerSources[i] < 0)
{
powerSources[i] = 0;
}
}
@ -288,28 +255,34 @@ public final class PowerHandler {
}
/**
* Extract energy from the PowerHandler. You must call this even if doWork()
* triggers.
*
* Extract energy from the PowerHandler. You must call this even if doWork() triggers.
*
* @param min
* @param max
* @param doUse
* @return amount used
*/
public float useEnergy(float min, float max, boolean doUse) {
public float useEnergy(float min, float max, boolean doUse)
{
applyPerdition();
float result = 0;
if (energyStored >= min) {
if (energyStored <= max) {
if (energyStored >= min)
{
if (energyStored <= max)
{
result = energyStored;
if (doUse) {
if (doUse)
{
energyStored = 0;
}
} else {
}
else
{
result = max;
if (doUse) {
if (doUse)
{
energyStored -= max;
}
}
@ -317,122 +290,137 @@ public final class PowerHandler {
validateEnergy();
// if (doUse)
// totalUsedPower += result;
return result;
}
public void readFromNBT(NBTTagCompound data) {
public void readFromNBT(NBTTagCompound data)
{
readFromNBT(data, "powerProvider");
}
public void readFromNBT(NBTTagCompound data, String tag) {
public void readFromNBT(NBTTagCompound data, String tag)
{
NBTTagCompound nbt = data.getCompoundTag(tag);
energyStored = nbt.getFloat("storedEnergy");
}
public void writeToNBT(NBTTagCompound data) {
public void writeToNBT(NBTTagCompound data)
{
writeToNBT(data, "powerProvider");
}
public void writeToNBT(NBTTagCompound data, String tag) {
public void writeToNBT(NBTTagCompound data, String tag)
{
NBTTagCompound nbt = new NBTTagCompound();
nbt.setFloat("storedEnergy", energyStored);
data.setCompoundTag(tag, nbt);
}
public final class PowerReceiver {
public final class PowerReceiver
{
private PowerReceiver() {
private PowerReceiver()
{
}
public float getMinEnergyReceived() {
public float getMinEnergyReceived()
{
return minEnergyReceived;
}
public float getMaxEnergyReceived() {
public float getMaxEnergyReceived()
{
return maxEnergyReceived;
}
public float getMaxEnergyStored() {
public float getMaxEnergyStored()
{
return maxEnergyStored;
}
public float getActivationEnergy() {
public float getActivationEnergy()
{
return activationEnergy;
}
public float getEnergyStored() {
public float getEnergyStored()
{
return energyStored;
}
public Type getType() {
public Type getType()
{
return type;
}
public void update() {
public void update()
{
PowerHandler.this.update();
}
/**
* The amount of power that this PowerHandler currently needs.
*
*
* @return
*/
public float powerRequest() {
public float powerRequest()
{
update();
return Math.min(maxEnergyReceived, maxEnergyStored - energyStored);
}
/**
* Add power to the PowerReceiver from an external source.
*
* IPowerEmitters are responsible for calling this themselves.
*
*
* @param quantity
* @param from
* @return the amount of power used
*/
public float receiveEnergy(Type source, final float quantity, ForgeDirection from) {
public float receiveEnergy(Type source, final float quantity, ForgeDirection from)
{
float used = quantity;
if (source == Type.ENGINE) {
if (used < minEnergyReceived) {
if (source == Type.ENGINE)
{
if (used < minEnergyReceived)
{
return 0;
} else if (used > maxEnergyReceived) {
}
else if (used > maxEnergyReceived)
{
used = maxEnergyReceived;
}
}
updateSources(from);
used -= used * getPerdition().getTaxPercent();
used = addEnergy(used);
applyWork();
if (source == Type.ENGINE && type.eatsEngineExcess()) {
used = Math.min(quantity, maxEnergyReceived);
if (source == Type.ENGINE && type.eatsEngineExcess())
{
return Math.min(quantity, maxEnergyReceived);
}
// totalReceivedPower += used;
return used;
}
}
/**
*
*
* @return the amount the power changed by
*/
public float addEnergy(float quantity) {
public float addEnergy(float quantity)
{
energyStored += quantity;
if (energyStored > maxEnergyStored) {
if (energyStored > maxEnergyStored)
{
quantity -= energyStored - maxEnergyStored;
energyStored = maxEnergyStored;
} else if (energyStored < 0) {
}
else if (energyStored < 0)
{
quantity -= energyStored;
energyStored = 0;
}
@ -442,20 +430,25 @@ public final class PowerHandler {
return quantity;
}
public void setEnergy(float quantity) {
public void setEnergy(float quantity)
{
this.energyStored = quantity;
validateEnergy();
}
public boolean isPowerSource(ForgeDirection from) {
public boolean isPowerSource(ForgeDirection from)
{
return powerSources[from.ordinal()] != 0;
}
private void validateEnergy() {
if (energyStored < 0) {
private void validateEnergy()
{
if (energyStored < 0)
{
energyStored = 0;
}
if (energyStored > maxEnergyStored) {
if (energyStored > maxEnergyStored)
{
energyStored = maxEnergyStored;
}
}

View file

@ -26,8 +26,6 @@ public interface IMetaDelegate extends IEnergyTile {
/**
* Get the sub-TileEntities belonging to this Meta TileEntity.
*
* @note the list has to be consistent between the EnergyNet Load and Unload events.
*
* @return sub-TileEntity array
*/
List<TileEntity> getSubTiles();

View file

@ -42,539 +42,346 @@ public final class Items {
/* Possible values:
// ores
copperOre; // Copper Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreCopper, null with enableWorldGenOreCopper=false
tinOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreTin, null with enableWorldGenOreTin=false
uraniumOre; // Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreUranium, null with enableWorldGenOreUranium=false
leadOre; // Lead Ore Block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreLead, null with enableWorldGenOreLead=false
// rubber related
Rubber wood block, meta reflects the state, meta in ItemStack set to 0, ore dictionary: woodRubber (with meta 0), null with enableWorldGenTreeRubber=false
dropped (as an item) -> metadata 0
block, no resin spot -> metadata 0 or 1
block, wet resin spot -> metadata 2-5 (according to the side)
block, dry resin spot -> metadata 8-11 (wet state + 6)
rubberWood;
rubberLeaves; // Rubber Leaves block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
rubberSapling; // Rubber Sapling block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
resinSheet; // Resin Sheet block, currently not meta sensitive
rubberTrampoline; // Rubber Trampoline block, meta reflects internal state, meta in ItemStack set to 0
// building/storage
ironFence; // Iron Fence block, currently not meta sensitive
reinforcedStone; // Reinforced Stone block, currently not meta sensitive
reinforcedGlass; // Reinforced Glass block, currently not meta sensitive
reinforcedDoorBlock; // Reinforced Door block, meta reflects the state (see vanilla doors), meta in ItemStack set to 0
constructionreinforcedFoam; // Construction Reinforced Foam block, currently not meta sensitive
constructionFoam; // Construction Foam block, currently not meta sensitive
constructionFoamWall; // Construction Foam Wall block, meta = color, implements IPaintableBlock
scaffold; // Scaffold block, meta reflects internal physical model data
ironScaffold; // Scaffold block, meta reflects internal physical model data
bronzeBlock; // Bronze block, meta sensitive
copperBlock; // Copper block, meta sensitive
tinBlock; // Tin block, meta sensitive
uraniumBlock; // Uranium block, meta sensitive
leadBlock; // Uranium block, meta sensitive
// cables (when placed as a block, inventory items are different; TE implements IEnergyConductor)
copperCableBlock; // Copper Cable block, meta sensitive
insulatedCopperCableBlock; // Insulated Copper Cable block, meta sensitive
goldCableBlock; // Gold Cable block, meta sensitive
insulatedGoldCableBlock; // Insulated Gold Cable block, meta sensitive
doubleInsulatedGoldCableBlock; // Double Insulated Gold Cable block, meta sensitive
ironCableBlock; // Iron Cable block, meta sensitive
insulatedIronCableBlock; // Insulated Iron Cable block, meta sensitive
doubleInsulatedIronCableBlock; // Double Insulated Iron Cable block, meta sensitive
trippleInsulatedIronCableBlock; // Tripple Insulated Iron Cable block, meta sensitive
glassFiberCableBlock; // Glass Fiber Cable block, meta sensitive
tinCableBlock; // Tin Cable block, meta sensitive
insulatedtinCableBlock; // Insulated Tin Cable item, meta sensitive
detectorCableBlock; // Detector Cable block, meta sensitive
splitterCableBlock; // Splitter Cable block, meta sensitive
// generators + related (TE implements IEnergySource ex. reactorChamber)
generator; // Generator block, meta sensitive
geothermalGenerator; // Geothermal Generator block, meta sensitive
waterMill; // Water Mill block, meta sensitive
solarPanel; // Solar Panel block, meta sensitive
windMill; // Wind Mill block, meta sensitive
nuclearReactor; // Nuclear Reactor block, meta sensitive
reactorChamber; // Reactor Chamber block, currently not meta sensitive
RTGenerator; // Radioisotope Thermoelectric Generator block, meta sensitive
semifluidGenerator; // Semifluid Generator block, meta sensitive
// energy storages (TE implements IEnergySource and IEnergyConductor)
batBox; // BatBox block, meta sensitive
cesuUnit; // CESU Unit block, meta sensitive
mfeUnit; // MFE Unit block, meta sensitive
mfsUnit; // MFS Unit block, meta sensitive
// transformers (TE implements IEnergySource and IEnergyConductor)
lvTransformer; // LV Transformer block, meta sensitive
mvTransformer; // MV Transformer block, meta sensitive
hvTransformer; // HV Transformer block, meta sensitive
evTransformer; // EV Transformer block, meta sensitive
// machines + related (TE implements IEnergySink ex. machine, miningPipe, miningPipeTip)
machine; // Machine block, meta sensitive
advancedMachine; // Advanced Machine block, meta sensitive
ironFurnace; // Iron Furnace block, meta sensitive
electroFurnace; // Electro Furnace block, meta sensitive
macerator; // Macerator block, meta sensitive
extractor; // Extractor block, meta sensitive
compressor; // Compressor block, meta sensitive
canner; // Canner block, meta sensitive
miner; // Miner block, meta sensitive
pump; // Pump block, meta sensitive
magnetizer; // Magnetizer block, meta sensitive
electrolyzer; // Electrolyzer block, meta sensitive
recycler; // Recycler block, meta sensitive
inductionFurnace; // Induction Furnace block, meta sensitive
massFabricator; // Mass Fabricator block, meta sensitive
terraformer; // Terraformer block, meta sensitive
teleporter; // Teleporter block, meta sensitive
teslaCoil; // Tesla Coil block, meta sensitive
luminator; // Passive (dark) Luminator block, meta = facing
activeLuminator; // Active (bright) Luminator block, meta = facing
centrifuge; // Centrifuge block, meta sensitive
metalformer; // MetalFormer block ,meta sensitive
orewashingplant; // Ore Wasching Plant,Meta sensitive
patternstorage; // Pattern Storage,Meta sensitive
scanner; // Scanner,Meta sensitive
replicator; // Replicator,Meta sensitive
miningPipe; // Mining Pipe block, currently not meta sensitive, meta in ItemStack set to 0
miningPipeTip; // Mining Pipe Tip block, currently not meta sensitive, meta in ItemStack set to 0
// personal blocks
personalSafe; // Personal Safe block, meta sensitive
tradeOMat; // Trade-O-Mat block, meta sensitive
energyOMat; // Energy-O-Mat block, meta sensitive
// explosives
industrialTnt; // Industrial TNT block, currently not meta sensitive
nuke; // Nuke block, currently not meta sensitive
dynamiteStick; // Dynamite Stick block, meta = placement, meta in ItemStack set to 0
dynamiteStickWithRemote; // Dynamite Stick with Remote block, meta = placement, meta in ItemStack set to 0
// Agriculture Stuff
crop; // Crop Block, empty, not meta sensitive
cropmatron; // Cropmatron machien block, meta sensititve
// ----- items -----
// rubber + related
resin; // Resin item, currently not meta sensitive
rubber; // Rubber item, currently not meta sensitive, ore dictionary: itemRubber
FluidCell;
// Lithium -> Tritium
reactorLithiumCell; // LithiumCell use in Reaktor, , meta = damage value
TritiumCell; // Tritium, currently not meta sensitive
// Nuclear Fuel
UranFuel; // , currently not meta sensitive
MOXFuel; // , currently not meta sensitive
Plutonium; // , currently not meta sensitive
smallPlutonium; // , currently not meta sensitive
Uran235; // , currently not meta sensitive
smallUran235; // , currently not meta sensitive
Uran238; // , currently not meta sensitive
reactorDepletedUraniumSimple; // Depleted Uranium Cell items, currently not meta sensitive
reactorDepletedUraniumDual;
reactorDepletedUraniumQuad;
reactorDepletedMOXSimple; // Depleted MOX Cell items, currently not meta sensitive
reactorDepletedMOXDual;
reactorDepletedMOXQuad;
reactorMOXSimple; // Depleted MOX Cell items, currently not meta sensitive
reactorMOXDual;
reactorMOXQuad;
RTGPellets;
// Recipe Parts
coil; // Coil, meta sensitive
elemotor; // electric motor, meta sensitive
powerunit; // Item Power Unit, meta sensitive
powerunitsmall; // Item Power Unit, meta sensitive
// ItemCasing
casingcopper; // Copper ItemCasing, meta sensitive
casingtin; // Tin ItemCasing, meta sensitive
casingbronze; // Bronze ItemCasing, meta sensitive
casinggold; // Gold ItemCasing, meta sensitive
casingiron; // Iron ItemCasing, meta sensitive
@Deprecated
casingadviron; // Refined Iron ItemCasing, meta sensitive
casinglead; // Lead ItemCasing, meta sensitive
// Crushed Ore
crushedIronOre; // Crushed Iron Ore, meta sensitive
crushedCopperOre; // Crushed Copper Ore, meta sensitive
crushedGoldOre; // Crushed Gold Ore, meta sensitive
crushedTinOre; // Crushed Tin Ore, meta sensitive
crushedUraniumOre; // Crushed Uranium Ore, meta sensitive
crushedSilverOre; // Crushed Silver Ore, meta sensitive
crushedLeadOre; // Crushed Lead Ore, meta sensitive
//Purify Crushed Ore
purifiedCrushedIronOre; // Purify Crushed Iron Ore, meta sensitive
purifiedCrushedCopperOre; // Purify Crushed Copper Ore, meta sensitive
purifiedCrushedGoldOre; // Purify Crushed Gold Ore, meta sensitive
purifiedCrushedTinOre; // Purify Crushed Tin Ore, meta sensitive
purifiedCrushedUraniumOre; // Purify Crushed Uranium Ore, meta sensitive
purifiedCrushedSilverOre; // Purify Crushed Silver Ore, meta sensitive
purifiedCrushedLeadOre; // Purify Crushed Lead Ore, meta sensitive
// dusts
stoneDust;
bronzeDust; // Bronze Dust item, meta sensitive, ore dictionary: dustBronze
clayDust; // Clay Dust item, meta sensitive, ore dictionary: dustClay
coalDust; // Coal Dust item, meta sensitive, ore dictionary: dustCoal
copperDust; // Copper Dust item, meta sensitive, ore dictionary: dustCopper
goldDust; // Gold Dust item, meta sensitive, ore dictionary: dustGold
ironDust; // Iron Dust item, meta sensitive, ore dictionary: dustIron
silverDust; // Silver Dust item, meta sensitive, ore dictionary: dustSilver
tinDust; // Tin Dust item, meta sensitive, ore dictionary: dustTin
hydratedCoalDust; // Hydrated Coal Dust item, meta sensitive
leadDust; // Lead Dust item, meta sensitive, ore dictionary: dustLead
obsidianDust; // Obsidian Dust item, meta sensitive, ore dictionary: dustObsidian
lapiDust; // Lapi Dust item, meta sensitive, ore dictionary: dustLapi
sulfurDust; // Sulfur Dust item, meta sensitive, ore dictionary: dustSulfur
lithiumDust; // Lithium dust, meta sensitive, ore dictionary: dustLithium
// small dusts
smallIronDust; // Small Iron Dust item, meta sensitive
smallCopperDust; // Small Copper Dust item, meta sensitive
smallGoldDust; // Small Gold Dust item, meta sensitive
smallTinDust; // Small Tin Dust item, meta sensitive
smallSilverDust; // Small Silver Dust item, meta sensitive
smallLeadDust; // Small Lead Dust item, meta sensitive
smallSulfurDust; // Small Sulfur Dust item, meta sensitive
smallLithiumDust; // Small Lithium Dust item, meta sensitive
// ingots
@Deprecated
refinedIronIngot; // Refined Iron Ingot item, currently not meta sensitive, ore dictionary: ingotRefinedIron
copperIngot; // Copper Ingot item, currently not meta sensitive, ore dictionary: ingotCopper
tinIngot; // Tin Ingot item, currently not meta sensitive, ore dictionary: ingotTin
bronzeIngot; // Bronze Ingot item, currently not meta sensitive, ore dictionary: ingotBronze
mixedMetalIngot; // Mixed Metal Ingot item, currently not meta sensitive
leadIngot; // Lead Ingot item, currently not meta sensitive
// tools/weapons (without electric tools)
treetap; // Treetap item, meta = damage value
wrench; // Wrench item, meta = damage value
cutter; // Insulation Cutter item, meta = damage value
constructionFoamSprayer; // Construction Foam Sprayer item, meta = charges (as of v1.45)
bronzePickaxe; // Bronze Pickaxe item, meta = damage value
bronzeAxe; // Bronze Axe item, meta = damage value
bronzeSword; // Bronze Sword item, meta = damage value
bronzeShovel; // Bronze Shovel item, meta = damage value
bronzeHoe; // Bronze Hoe item, meta = damage value
ForgeHammer; // Refine Iron Hammer item, meta = damage value
// el. tools/devices/weapons
miningDrill; // Mining Drill item, meta = damage value for charge level
diamondDrill; // Diamond Tipped Mining Drill item, meta = damage value for charge level
iridiumDrill; // Iridium Tipped Mining Drill item, meta = damage value for charge level
chainsaw; // Chainsaw item, meta = damage value for charge level
electricWrench; // Electric Wrench item, meta = damage value for charge level
electricTreetap; // Electric Treetap item, meta = damage value for charge level
miningLaser; // Mining Laser item, meta = damage value for charge level
ecMeter; // EC-Mater item, meta = itemdata db index (as of v1.45)
odScanner; // Ore Density Scanner item, meta = damage value for charge level
ovScanner; // Ore Value Scanner item, meta = damage value for charge level
obscurator; // Obscurator item, meta = damage value for charge level
frequencyTransmitter; // Frequency Transmitter item, meta = itemdata db index (as of v1.45)
nanoSaber; // Idle Nano Saber item, meta = damage value for charge level
enabledNanoSaber; // Enabled Nano Saber item, meta = damage value for charge level
toolbox; // Open/Empty toolbox, meta = Open (0) / Closed (1)
// armor/wearable
hazmatHelmet; // Hazmat Helmet item, meta = damage value
hazmatChestplate; // Hazmat Chestplate item, meta = damage value
hazmatLeggings; // Hazmat Leggings item, meta = damage value
hazmatBoots; // Hazmat Boots item, meta = damage value
bronzeHelmet; // Bronze Helmet Armor item, meta = damage value
bronzeChestplate; // Bronze Chestplate Armor item, meta = damage value
bronzeLeggings; // Bronze Leggings Armor item, meta = damage value
bronzeBoots; // Bronze Boots Armor item, meta = damage value
compositeArmor; // Composite Armor item, meta = damage value for charge level
nanoHelmet; // Nano Helmet Armor item, meta = damage value for charge level
nanoBodyarmor; // Nano Bodyarmor item, meta = damage value for charge level
nanoLeggings; // Nano Leggings Armor item, meta = damage value for charge level
nanoBoots; // Nano Boots Armor item, meta = damage value for charge level
quantumHelmet; // Quantum Helmet Armor item, meta = damage value for charge level
quantumBodyarmor; // Quantum Bodyarmor item, meta = damage value for charge level
quantumLeggings; // Quantum Leggings Armor item, meta = damage value for charge level
quantumBoots; // Quantum Boots Armor item, meta = damage value for charge level
jetpack; // Jetpack item, meta = damage value for fuel level
electricJetpack; // Electric Jetpack item, meta = damage value for charge level
batPack; // BatPack item, meta = damage value for charge level
advbatPack; // Adv.BatPack item, meta = damage value for charge level
lapPack; // LapPack item, meta = damage value for charge level
energyPack; // EnergyPack item, meta = damage value for charge level
cfPack; // CF Pack item, meta = charges (as of v1.45)
solarHelmet; // Solar Helmet, currently not meta sensitive
staticBoots; // Static Boots, currently not meta sensitive
nightvisionGoggles; // Nightvision Goggles, meta = damage value for charge level
// batteries
reBattery; // Empty RE Battery item, currently not meta sensitive
chargedReBattery; // RE Battery item, meta = damage value for charge level
advBattery; // Adv Batteryitem, meta = damage value for charge level
energyCrystal; // Energy Crystal item, meta = damage value for charge level
lapotronCrystal; // Lapotron Crystal item, meta = damage value for charge level
suBattery; // SU Battery item, meta = damage value for charge level
// cables
copperCableItem; // Copper Cable item, meta sensitive
insulatedCopperCableItem; // Insulated Copper Cable item, meta sensitive
goldCableItem; // Gold Cable item, meta sensitive
insulatedGoldCableItem; // Insulated Gold Cable item, meta sensitive
@Deprecated
doubleInsulatedGoldCableItem; // Double Insulated Gold Cable item, meta sensitive
ironCableItem; // Iron Cable item, meta sensitive
insulatedIronCableItem; // Insulated Iron Cable item, meta sensitive
@Deprecated
doubleInsulatedIronCableItem; // Double Insulated Iron Cable item, meta sensitive
@Deprecated
trippleInsulatedIronCableItem; // Tripple Insulated Iron Cable item, meta sensitive
insulatedTinCableItem;
glassFiberCableItem; // Glass Fiber Cable item, meta sensitive
tinCableItem; // Tin Cable item, meta sensitive
detectorCableItem; // Detector Cable item, meta sensitive
splitterCableItem; // Splitter Cable item, meta sensitive
// cells/containers (without reactor components)
cell; // Empty Cell item, meta sensitive
lavaCell; // Lava Cell item, meta sensitive
waterCell; // Water Cell item, meta sensitive
UuMatterCell; // UUMatter Cell item, meta sensitive
CFCell; // constructionFoam Cell item, meta sensitive
fuelRod; // Empy Fuel Rod item, currently not meta sensitive
hydratedCoalCell; // Hydrated Coal Cell item, currently not meta sensitive
bioCell; // Bio Cell item, currently not meta sensitive
coalfuelCell; // Coalfuel Cell item, currently not meta sensitive
biofuelCell; // Biofuel Cell item, currently not meta sensitive
electrolyzedWaterCell; // Electrolyzed Water Cell item, currently not meta sensitive
airCell; // Compressed Air item, currently not meta sensitive
fuelCan; // Empty Fuel Can item, currently not meta sensitive
filledFuelCan; // Fuel Can item, meta = fuel value (as of v1.45)
tinCan; // Empty Tin Can item, currently not meta sensitive
filledTinCan; // Filled Tin Can item, currently not meta sensitive
// reactor components
reactorUraniumSimple; // Uranium Cell items, meta = consumed uranium ticks
reactorUraniumDual;
reactorUraniumQuad;
reactorCoolantSimple;
reactorCoolantTriple ; // Coolant Cell item, NBT for heat-storage, meta is 0-10000 for display
reactorCoolantSix;
reactorPlating; // Integrated Reactor Plating item, currently not meta sensitive
reactorPlatingHeat;
reactorPlatingExplosive;
reactorHeatSwitch; // Integrated Heat Disperser item, NBT for heat-storage, meta is 0-10000 for display
reactorHeatSwitchCore;
reactorHeatSwitchSpread;
reactorHeatSwitchDiamond;
reactorVent; // Heat Venting component, NBT for heat-storage, meta is 0-10000 for display
reactorVentCore;
reactorVentGold;
reactorVentSpread;// Special: Does not store heat
reactorVentDiamond;
reactorReflector; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display
reactorReflectorThick; // Increase efficiency without additional ticks, NBT for heat-storage, meta is 0-10000 for display
reactorCondensator; // Consumes redstone to absorb heat, NBT for storage, meta is 0-10000 for display
reactorCondensatorLap; // Consumes redstone/lapis to absorb heat, mNBT for storage, meta is 0-10000 for display
// terraformer blueprints
terraformerBlueprint; // Empty Terraformer Blueprint item, currently not meta sensitive
cultivationTerraformerBlueprint; // Cultivation Terraformer Blueprint item, currently not meta sensitive
irrigationTerraformerBlueprint; // Irrigation Terraformer Blueprint item, currently not meta sensitive
chillingTerraformerBlueprint; // Chilling Terraformer Blueprint item, currently not meta sensitive
desertificationTerraformerBlueprint; // Desertification Terraformer Blueprint item, currently not meta sensitive
flatificatorTerraformerBlueprint; // Flatificator Terraformer Blueprint item, currently not meta sensitive
mushroomTerraformerBlueprint; // Mushroom Terraformer Blueprint item, currently not meta sensitive
// diamond chain
coalBall; // Coal Ball item, currently not meta sensitive
compressedCoalBall; // Compressed Coal Ball item, currently not meta sensitive
coalChunk; // Coal Chunk item, currently not meta sensitive
industrialDiamond; // Industrial Diamond item, currently not meta sensitive, DEPRECATED
// recycler chain
scrap; // Scrap item, currently not meta sensitive
scrapBox; // Scrap Box item, currently not meta sensitive
// fuel production chain
hydratedCoalClump; // Hydrated Coal Clump item, currently not meta sensitive
plantBall; // Plant Ball item, currently not meta sensitive
compressedPlantBall; // Compressed Plant Ball item, currently not meta sensitive
// painting
painter; // Painter item, currently not meta sensitive
blackPainter; // Black Painter item, meta = damage value
redPainter; // Red Painter item, meta = damage value
greenPainter; // Green Painter item, meta = damage value
brownPainter; // Brown Painter item, meta = damage value
bluePainter; // Blue Painter item, meta = damage value
purplePainter; // Purple Painter item, meta = damage value
cyanPainter; // Cyan Painter item, meta = damage value
lightGreyPainter; // Light Grey Painter item, meta = damage value
darkGreyPainter; // Dark Grey Painter item, meta = damage value
pinkPainter; // Pink Painter item, meta = damage value
limePainter; // Lime Painter item, meta = damage value
yellowPainter; // Yellow Painter item, meta = damage value
cloudPainter; // Cloud Painter item, meta = damage value
magentaPainter; // Magenta Painter item, meta = damage value
orangePainter; // Orange Painter item, meta = damage value
whitePainter; // White Painter item, meta = damage value
// explosives + related
dynamite; // Throwable Dynamite item, currently not meta sensitive
stickyDynamite; // Throwable Sticky Dynamite item, currently not meta sensitive
remote; // Dynamite Remote item, currently not meta sensitive
// misc intermediate recipe ingredients
electronicCircuit; // Electronic Circuit item, currently not meta sensitive
advancedCircuit; // Advanced Circuit item, currently not meta sensitive
advancedAlloy; // Advanced Alloy item, currently not meta sensitive
carbonFiber; // Raw Carbon Fiber item, currently not meta sensitive
carbonMesh; // Raw Carbon Mesh item, currently not meta sensitive
carbonPlate; // Carbon Plate item, currently not meta sensitive
matter; // UUA item, currently not meta sensitive
iridiumOre; // Iridium Ore item, currently not meta sensitive
iridiumPlate; // Iridium Plate item, currently not meta sensitive
// Metal Plates
platecopper; // Metal plate item, meta sensitive
platetin; // Metal plate item, meta sensitive
platebronze; // Metal plate item, meta sensitive
plategold; // Metal plate item, meta sensitive
plateiron; // Metal plate item, meta sensitive
platelead; // Metal plate item, meta sensitive
platelapi; // Metal plate item, meta sensitive
plateobsidian; // Metal plate item, meta sensitive
plateadviron; // Metal plate item, meta sensitive
// Metal Dense Plates
denseplatecopper; // Metal dense plate item, meta sensitive
denseplatetin; // Metal dense plate item, meta sensitive
denseplatebronze; // Metal dense plate item, meta sensitive
denseplategold; // Metal dense plate item, meta sensitive
denseplateiron; // Metal dense plate item, meta sensitive
@Deprecated
denseplateadviron; // Metal dense plate item, meta sensitive
denseplatelead; // Metal dense plate item, meta sensitive
denseplatelapi; // Metal dense plate item, meta sensitive
denseplateobsidian; // Metal dense plate item, meta sensitive
// upgrade modules
overclockerUpgrade; // overclocker upgrade item, meta sensitive
transformerUpgrade; // transformer upgrade item, meta sensitive
energyStorageUpgrade; // energy storage upgrade item, meta sensitive
ejectorUpgrade; // ejector upgrade item, meta sensitive
// misc
coin; // Coin item, currently not meta sensitive
reinforcedDoor; // Reinforced Door item, currently not meta sensitive
constructionFoamPowder; // Construction Foam Powder item, currently not meta sensitive
grinPowder; // Poisonous ingrident, currently not meta sensitive
debug; // Debug item, currently not meta sensitive
boatCarbon; // Carbon Fiber Canoe item, meta sensitive
boatRubber; // Rubber Dinghy item, meta sensitive
boatRubberBroken; // Damaged Rubber Dinghy item, meta sensitive
boatElectric; // Electric Boat item, meta sensitive
//Agriculture
cropSeed; // Crop seeds, stuff stored in NBT, don't use for crafting recipes!
cropnalyzer; // Cropnalyzer handheld device
fertilizer; // Basic IC2Item, used to provide nutrients toCropBlocks
hydratingCell; // Cell used to hydrate Crops, meta = Content, 0= Full, 9999 = Near empty
electricHoe; // Electric Hoe, Metadata indicates charge level
terraWart; // Mystic opposite of NEtherWart, cures StatusEffects, simply consumeable
weedEx; // Spraying can of WEED-EX, meta indicates usages left
//Boozeception
mugEmpty; // Simple stone mug
coffeeBeans; // Harvested CoffeeBeans
coffeePowder; // Processed Coffee Beans, used to craft drinkable Coffee
mugCoffee; // Mug of Coffee, Meta indicates status 0 = cold, 1 = Normal, 2 = Sugar'd
hops; // Hops, harvested freshly from crop
barrel; // Carried Barrel, metadata encrypts the information about the liquid inside
blockBarrel; // Unobtainable "placed barrel", TileEntity controlling the Fermentation process
mugBooze; // Mug filled with booze, metadata encrypts the information about the liquid inside
----- blocks -----
ores
copperOre Copper Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreCopper, null with enableWorldGenOreCopper=false
tinOre Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreTin, null with enableWorldGenOreTin=false
uraniumOre Tin Ore block, currently not meta sensitive, meta in ItemStack set to 0, ore dictionary: oreUranium, null with enableWorldGenOreUranium=false
rubber related
Rubber wood block, meta reflects the state, meta in ItemStack set to 0, ore dictionary: woodRubber (with meta 0), null with enableWorldGenTreeRubber=false
dropped (as an item) -> metadata 0
block, no resin spot -> metadata 0 or 1
block, wet resin spot -> metadata 2-5 (according to the side)
block, dry resin spot -> metadata 8-11 (wet state + 6)
rubberWood
rubberLeaves Rubber Leaves block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
rubberSapling Rubber Sapling block, currently not meta sensitive, meta in ItemStack set to 0, null with enableWorldGenTreeRubber=false
resinSheet Resin Sheet block, currently not meta sensitive
rubberTrampoline Rubber Trampoline block, meta reflects internal state, meta in ItemStack set to 0
building/storage
ironFence Iron Fence block, currently not meta sensitive
reinforcedStone Reinforced Stone block, currently not meta sensitive
reinforcedGlass Reinforced Glass block, currently not meta sensitive
reinforcedDoorBlock Reinforced Door block, meta reflects the state (see vanilla doors), meta in ItemStack set to 0
constructionFoam Construction Foam block, currently not meta sensitive
constructionFoamWall Construction Foam Wall block, meta = color, implements IPaintableBlock
scaffold Scaffold block, meta reflects internal physical model data
bronzeBlock Bronze block, meta sensitive
copperBlock Copper block, meta sensitive
tinBlock Tin block, meta sensitive
uraniumBlock Uranium block, meta sensitive
cables (when placed as a block, inventory items are different TE implements IEnergyConductor)
copperCableBlock Copper Cable block, meta sensitive
insulatedCopperCableBlock Insulated Copper Cable block, meta sensitive
goldCableBlock Gold Cable block, meta sensitive
insulatedGoldCableBlock Insulated Gold Cable block, meta sensitive
doubleInsulatedGoldCableBlock Double Insulated Gold Cable block, meta sensitive
ironCableBlock Iron Cable block, meta sensitive
insulatedIronCableBlock Insulated Iron Cable block, meta sensitive
doubleInsulatedIronCableBlock Double Insulated Iron Cable block, meta sensitive
trippleInsulatedIronCableBlock Tripple Insulated Iron Cable block, meta sensitive
glassFiberCableBlock Glass Fiber Cable block, meta sensitive
tinCableBlock Tin Cable block, meta sensitive
detectorCableBlock Detector Cable block, meta sensitive
splitterCableBlock Splitter Cable block, meta sensitive
generators + related (TE implements IEnergySource ex. reactorChamber)
generator Generator block, meta sensitive
geothermalGenerator Geothermal Generator block, meta sensitive
waterMill Water Mill block, meta sensitive
solarPanel Solar Panel block, meta sensitive
windMill Wind Mill block, meta sensitive
nuclearReactor Nuclear Reactor block, meta sensitive
reactorChamber Reactor Chamber block, currently not meta sensitive
energy storages (TE implements IEnergySource and IEnergyConductor)
batBox BatBox block, meta sensitive
mfeUnit MFE Unit block, meta sensitive
mfsUnit MFS Unit block, meta sensitive
transformers (TE implements IEnergySource and IEnergyConductor)
lvTransformer LV Transformer block, meta sensitive
mvTransformer MV Transformer block, meta sensitive
hvTransformer HV Transformer block, meta sensitive
machines + related (TE implements IEnergySink ex. machine, miningPipe, miningPipeTip)
machine Machine block, meta sensitive
advancedMachine Advanced Machine block, meta sensitive
ironFurnace Iron Furnace block, meta sensitive
electroFurnace Electro Furnace block, meta sensitive
macerator Macerator block, meta sensitive
extractor Extractor block, meta sensitive
compressor Compressor block, meta sensitive
canner Canner block, meta sensitive
miner Miner block, meta sensitive
pump Pump block, meta sensitive
magnetizer Magnetizer block, meta sensitive
electrolyzer Electrolyzer block, meta sensitive
recycler Recycler block, meta sensitive
inductionFurnace Induction Furnace block, meta sensitive
massFabricator Mass Fabricator block, meta sensitive
terraformer Terraformer block, meta sensitive
teleporter Teleporter block, meta sensitive
teslaCoil Tesla Coil block, meta sensitive
luminator Passive (dark) Luminator block, meta = facing
activeLuminator Active (bright) Luminator block, meta = facing
miningPipe Mining Pipe block, currently not meta sensitive, meta in ItemStack set to 0
miningPipeTip Mining Pipe Tip block, currently not meta sensitive, meta in ItemStack set to 0
personal blocks
personalSafe Personal Safe block, meta sensitive
tradeOMat Trade-O-Mat block, meta sensitive
energyOMat Energy-O-Mat block, meta sensitive
explosives
industrialTnt Industrial TNT block, currently not meta sensitive
nuke Nuke block, currently not meta sensitive
dynamiteStick Dynamite Stick block, meta = placement, meta in ItemStack set to 0
dynamiteStickWithRemote Dynamite Stick with Remote block, meta = placement, meta in ItemStack set to 0
Agriculture Stuff
crop Crop Block, empty, not meta sensitive
----- items -----
rubber + related
resin Resin item, currently not meta sensitive
rubber Rubber item, currently not meta sensitive, ore dictionary: itemRubber
ore drops
uraniumDrop Uranium Drop item, currently not meta sensitive, ore dictionary: itemDropUranium
dusts
bronzeDust Bronze Dust item, currently not meta sensitive
clayDust Clay Dust item, currently not meta sensitive
coalDust Coal Dust item, currently not meta sensitive
copperDust Copper Dust item, currently not meta sensitive
goldDust Gold Dust item, currently not meta sensitive
ironDust Iron Dust item, currently not meta sensitive
silverDust Silver Dust item, currently not meta sensitive
smallIronDust Small Iron Dust item, currently not meta sensitive
tinDust Tin Dust item, currently not meta sensitive
hydratedCoalDust Hydrated Coal Dust item, currently not meta sensitive
ingots
refinedIronIngot Refined Iron Ingot item, currently not meta sensitive, ore dictionary: ingotRefinedIron
copperIngot Copper Ingot item, currently not meta sensitive, ore dictionary: ingotCopper
tinIngot Tin Ingot item, currently not meta sensitive, ore dictionary: ingotTin
bronzeIngot Bronze Ingot item, currently not meta sensitive, ore dictionary: ingotBronze
mixedMetalIngot Mixed Metal Ingot item, currently not meta sensitive
uraniumIngot Uranium Ingot item, currently not meta sensitive, ore dictionary: ingotUranium
tools/weapons (without electric tools)
treetap Treetap item, meta = damage value
wrench Wrench item, meta = damage value
cutter Insulation Cutter item, meta = damage value
constructionFoamSprayer Construction Foam Sprayer item, meta = charges (as of v1.45)
bronzePickaxe Bronze Pickaxe item, meta = damage value
bronzeAxe Bronze Axe item, meta = damage value
bronzeSword Bronze Sword item, meta = damage value
bronzeShovel Bronze Shovel item, meta = damage value
bronzeHoe Bronze Hoe item, meta = damage value
el. tools/devices/weapons
miningDrill Mining Drill item, meta = visual charge indicator, implements IElectricItem
diamondDrill Diamond Tipped Mining Drill item, meta = visual charge indicator, implements IElectricItem
chainsaw Chainsaw item, meta = visual charge indicator, implements IElectricItem
electricWrench Electric Wrench item, meta = visual charge indicator, implements IElectricItem
electricTreetap Electric Treetap item, meta = visual charge indicator, implements IElectricItem
miningLaser Mining Laser item, meta = visual charge indicator, implements IElectricItem
ecMeter EC-Mater item, currently not meta sensitive
odScanner Ore Density Scanner item, meta = damage value for charge level, implements IElectricItem
ovScanner Ore Value Scanner item, meta = visual charge indicator, implements IElectricItem
frequencyTransmitter Frequency Transmitter item, currently not meta sensitive
nanoSaber Idle Nano Saber item, meta = visual charge indicator, implements IElectricItem
enabledNanoSaber Enabled Nano Saber item, meta = visual charge indicator, implements IElectricItem
armor/wearable
rubberBoots Rubber Boots item, meta = damage value
bronzeHelmet Bronze Helmet Armor item, meta = damage value
bronzeChestplate Bronze Chestplate Armor item, meta = damage value
bronzeLeggings Bronze Leggings Armor item, meta = damage value
bronzeBoots Bronze Boots Armor item, meta = damage value
compositeArmor Composite Armor item, meta = damage value for charge level
nanoHelmet Nano Helmet Armor item, meta = visual charge indicator, implements IElectricItem
nanoBodyarmor Nano Bodyarmor item, meta = visual charge indicator, implements IElectricItem
nanoLeggings Nano Leggings Armor item, meta = visual charge indicator, implements IElectricItem
nanoBoots Nano Boots Armor item, meta = visual charge indicator, implements IElectricItem
quantumHelmet Quantum Helmet Armor item, meta = visual charge indicator, implements IElectricItem
quantumBodyarmor Quantum Bodyarmor item, meta = visual charge indicator, implements IElectricItem
quantumLeggings Quantum Leggings Armor item, meta = visual charge indicator, implements IElectricItem
quantumBoots Quantum Boots Armor item, meta = visual charge indicator, implements IElectricItem
jetpack Jetpack item, meta = damage value for fuel level
electricJetpack Electric Jetpack item, meta = visual charge indicator, implements IElectricItem
batPack BatPack item, meta = visual charge indicator, implements IElectricItem, can provide energy
lapPack LapPack item, meta = visual charge indicator, implements IElectricItem, can provide energy
cfPack CF Pack item, meta = charges (as of v1.45)
solarHelmet Solar Helmet item, currently not meta sensitive
staticBoots Static Boots item, currently not meta sensitive
batteries
reBattery Empty RE Battery item, currently not meta sensitive, implements IElectricItem
chargedReBattery RE Battery item, meta = visual charge indicator, implements IElectricItem, can provide energy
energyCrystal Energy Crystal item, meta = visual charge indicator, implements IElectricItem, can provide energy
lapotronCrystal Lapotron Crystal item, meta = visual charge indicator, implements IElectricItem, can provide energy
suBattery SU Battery item, currently not meta sensitive
cables
copperCableItem Copper Cable item, meta sensitive
insulatedCopperCableItem Insulated Copper Cable item, meta sensitive
goldCableItem Gold Cable item, meta sensitive
insulatedGoldCableItem Insulated Gold Cable item, meta sensitive
doubleInsulatedGoldCableItem Double Insulated Gold Cable item, meta sensitive
ironCableItem Iron Cable item, meta sensitive
insulatedIronCableItem Insulated Iron Cable item, meta sensitive
doubleInsulatedIronCableItem Double Insulated Iron Cable item, meta sensitive
trippleInsulatedIronCableItem Tripple Insulated Iron Cable item, meta sensitive
glassFiberCableItem Glass Fiber Cable item, meta sensitive
tinCableItem Tin Cable item, meta sensitive
detectorCableItem Detector Cable item, meta sensitive
splitterCableItem Splitter Cable item, meta sensitive
cells/containers (without reactor components)
cell Empty Cell item, currently not meta sensitive
lavaCell Lava Cell item, currently not meta sensitive
hydratedCoalCell Hydrated Coal Cell item, currently not meta sensitive
bioCell Bio Cell item, currently not meta sensitive
coalfuelCell Coalfuel Cell item, currently not meta sensitive
biofuelCell Biofuel Cell item, currently not meta sensitive
waterCell Water Cell item, currently not meta sensitive
electrolyzedWaterCell Electrolyzed Water Cell item, currently not meta sensitive
fuelCan Empty Fuel Can item, currently not meta sensitive
filledFuelCan Fuel Can item, meta = fuel value (as of v1.45)
tinCan Empty Tin Can item, currently not meta sensitive
filledTinCan Filled Tin Can item, currently not meta sensitive
reactor components
uraniumCell Uranium Cell item, meta = damage value
coolingCell Cooling Cell item, meta = damage value
depletedIsotopeCell Depleted Isotope Cell item, meta = damage value
reEnrichedUraniumCell Re-Enriched Uranium Cell item, currently not meta sensitive
nearDepletedUraniumCell Near-Depleted Uranium Cell item, currently not meta sensitive
integratedReactorPlating Integrated Reactor Plating item, meta = damage value
integratedHeatDisperser Integrated Heat Disperser item, meta = damage value
terraformer blueprints
terraformerBlueprint Empty Terraformer Blueprint item, currently not meta sensitive
cultivationTerraformerBlueprint Cultivation Terraformer Blueprint item, currently not meta sensitive
irrigationTerraformerBlueprint Irrigation Terraformer Blueprint item, currently not meta sensitive
chillingTerraformerBlueprint Chilling Terraformer Blueprint item, currently not meta sensitive
desertificationTerraformerBlueprint Desertification Terraformer Blueprint item, currently not meta sensitive
flatificatorTerraformerBlueprint Flatificator Terraformer Blueprint item, currently not meta sensitive
mushroomTerraformerBlueprint Mushroom Terraformer Blueprint item, currently not meta sensitive
diamond chain
coalBall Coal Ball item, currently not meta sensitive
compressedCoalBall Compressed Coal Ball item, currently not meta sensitive
coalChunk Coal Chunk item, currently not meta sensitive
industrialDiamond Industrial Diamond item, currently not meta sensitive, DEPRECATED
recycler chain
scrap Scrap item, currently not meta sensitive
scrapBox Scrap Box item, currently not meta sensitive
fuel production chain
hydratedCoalClump Hydrated Coal Clump item, currently not meta sensitive
plantBall Plant Ball item, currently not meta sensitive
compressedPlantBall Compressed Plant Ball item, currently not meta sensitive
painting
painter Painter item, currently not meta sensitive
blackPainter Black Painter item, meta = damage value
redPainter Red Painter item, meta = damage value
greenPainter Green Painter item, meta = damage value
brownPainter Brown Painter item, meta = damage value
bluePainter Blue Painter item, meta = damage value
purplePainter Purple Painter item, meta = damage value
cyanPainter Cyan Painter item, meta = damage value
lightGreyPainter Light Grey Painter item, meta = damage value
darkGreyPainter Dark Grey Painter item, meta = damage value
pinkPainter Pink Painter item, meta = damage value
limePainter Lime Painter item, meta = damage value
yellowPainter Yellow Painter item, meta = damage value
cloudPainter Cloud Painter item, meta = damage value
magentaPainter Magenta Painter item, meta = damage value
orangePainter Orange Painter item, meta = damage value
whitePainter White Painter item, meta = damage value
explosives + related
dynamite Throwable Dynamite item, currently not meta sensitive
stickyDynamite Throwable Sticky Dynamite item, currently not meta sensitive
remote Dynamite Remote item, currently not meta sensitive
misc intermediate recipe ingredients
electronicCircuit Electronic Circuit item, currently not meta sensitive
advancedCircuit Advanced Circuit item, currently not meta sensitive
advancedAlloy Advanced Alloy item, currently not meta sensitive
carbonFiber Raw Carbon Fiber item, currently not meta sensitive
carbonMesh Raw Carbon Mesh item, currently not meta sensitive
carbonPlate Carbon Plate item, currently not meta sensitive
matter UU-Matter item, currently not meta sensitive
iridiumOre Iridium Ore item, currently not meta sensitive
iridiumPlate Iridium Plate item, currently not meta sensitive
upgrade modules
overclockerUpgrade overclocker upgrade item, meta sensitive
transformerUpgrade transformer upgrade item, meta sensitive
energyStorageUpgrade energy storage upgrade item, meta sensitive
misc
coin Coin item, currently not meta sensitive
reinforcedDoor Reinforced Door item, currently not meta sensitive
constructionFoamPellet Construction Foam Pellet item, currently not meta sensitive
cropSeed Crop seeds, stuff stored in NBT, don't use for crafting recipes!
cropnalyzer Cropnalyzer handheld device
fertilizer Basic IC2Item, used to provide nutrients toCropBlocks
hydratingCell Cell used to hydrate Crops, meta = Content, 0 = Full, 9999 = Near empty
electricHoe Electric Hoe, meta = charge level
solarHelmet Solar Helmet item, currently not meta sensitive
terraWart Terra Wart item, cures potion effects
weedEx Weed-EX can, meta = uses left
*/

View file

@ -12,34 +12,45 @@ import cpw.mods.fml.common.Loader;
*/
public class Compatibility
{
/** Version of build craft api compiled with */
/** Version of BuildCraft api compiled with */
public static String BCx_VERSION = "@BCxVersion@";
/** Version of industrial craft api compiled with */
/** Version of Industrial Craft api compiled with */
public static String ICx_VERSION = "@ICxVersion@";
/** Version of thermal expansion api compiled with */
/** Version of Thermal Expansion api compiled with */
public static String TEx_VERSION = "@TExVersion@";
/** Has the initiate method been called */
public static boolean INIT = false;
/** Ratio of Build craft(MJ) power to UE power(KW). Multiply BC3 power by this to convert to UE */
/** Ratio of Build craft(MJ) power to UE power(Kw). Multiply BC3 power by this to convert to UE */
public static float BC3_RATIO = 2.814f;
/** Ratio of Redstone Flux power to UE power(Kw). Multiply TE power by this to convert to UE */
public static float TE_RATIO = BC3_RATIO / 10;
/**
* Ratio of Industrial craft(EU) power to UE power(KW). Multiply IC2 power by this to convert to
* Ratio of Industrial craft(EU) power to UE power(Kw). Multiply IC2 power by this to convert to
* UE
*/
public static float IC2_RATIO = 0.11256f;
/**
* Ratio of UE power(Kw) to Build craft(MJ) power. Multiply UE power by this to convert it to
* BC3 power
*/
public static float TO_BC_RATIO = 1 / BC3_RATIO;
/**
* Ratio of UE power(Kw) to Redstone Flux power. Multiply UE power by this to convert it to TE
* power
*/
public static float TO_TE_RATIO = 1 / TE_RATIO;
/**
* Ratio of UE power(KW) to Industrial craft(EU) power. Multiply UE power by this to convert it
* to IC2 power
*/
public static float TO_IC2_RATIO = 1 / IC2_RATIO;
/**
* Ratio of UE power(KW) to Build craft(MJ) power. Multiply UE power by this to convert it to
* BC3 power
*/
public static float TO_BC_RATIO = 1 / BC3_RATIO;
/** You must call this function to enable the Universal Network module. */
public static void initiate()
@ -55,6 +66,7 @@ public class Compatibility
/** Loads the configuration and sets all the values. */
UniversalElectricity.CONFIGURATION.load();
IC2_RATIO = (float) UniversalElectricity.CONFIGURATION.get("Compatiblity", "IndustrialCraft Conversion Ratio", IC2_RATIO).getDouble(IC2_RATIO);
TE_RATIO = (float) UniversalElectricity.CONFIGURATION.get("Compatiblity", "Thermal Expansion Conversion Ratio", TE_RATIO).getDouble(TE_RATIO);
BC3_RATIO = (float) UniversalElectricity.CONFIGURATION.get("Compatiblity", "BuildCraft Conversion Ratio", BC3_RATIO).getDouble(BC3_RATIO);
TO_IC2_RATIO = 1 / IC2_RATIO;
TO_BC_RATIO = 1 / BC3_RATIO;
@ -76,5 +88,8 @@ public class Compatibility
return Loader.isModLoaded("BuildCraft|Energy");
}
// TODO add Thermal expansion isLoaded check
public static boolean isThermalExpansionLoaded()
{
return Loader.isModLoaded("ThermalExpansion");
}
}

View file

@ -4,11 +4,11 @@ import ic2.api.item.IElectricItemManager;
import ic2.api.item.ISpecialElectricItem;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.ItemStack;
import thermalexpansion.api.item.IChargeableItem;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.item.ItemElectric;
import cofh.api.energy.IEnergyContainerItem;
public abstract class ItemUniversalElectric extends ItemElectric implements ISpecialElectricItem, IChargeableItem
public abstract class ItemUniversalElectric extends ItemElectric implements ISpecialElectricItem, IEnergyContainerItem
{
public static final float CHARGE_RATE = 0.005f;
@ -66,27 +66,27 @@ public abstract class ItemUniversalElectric extends ItemElectric implements ISpe
* Thermal Expansion
*/
@Override
public float receiveEnergy(ItemStack theItem, float energy, boolean doReceive)
public int receiveEnergy(ItemStack theItem, int energy, boolean doReceive)
{
return this.recharge(theItem, energy * Compatibility.BC3_RATIO, doReceive) * Compatibility.TO_BC_RATIO;
return (int) (this.recharge(theItem, energy * Compatibility.BC3_RATIO, doReceive) * Compatibility.TO_BC_RATIO);
}
@Override
public float transferEnergy(ItemStack theItem, float energy, boolean doTransfer)
public int extractEnergy(ItemStack theItem, int energy, boolean doTransfer)
{
return this.discharge(theItem, energy * Compatibility.BC3_RATIO, doTransfer) * Compatibility.TO_BC_RATIO;
return (int) (this.discharge(theItem, energy * Compatibility.BC3_RATIO, doTransfer) * Compatibility.TO_BC_RATIO);
}
@Override
public float getEnergyStored(ItemStack theItem)
public int getEnergyStored(ItemStack theItem)
{
return this.getElectricityStored(theItem) * Compatibility.TO_BC_RATIO;
return (int) (this.getElectricityStored(theItem) * Compatibility.TO_BC_RATIO);
}
@Override
public float getMaxEnergyStored(ItemStack theItem)
public int getMaxEnergyStored(ItemStack theItem)
{
return this.getMaxElectricityStored(theItem) * Compatibility.TO_BC_RATIO;
return (int) (this.getMaxElectricityStored(theItem) * Compatibility.TO_BC_RATIO);
}
public static class IC2ElectricItemManager implements IElectricItemManager

View file

@ -12,7 +12,6 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.common.MinecraftForge;
import thermalexpansion.api.item.IChargeableItem;
import universalelectricity.core.electricity.ElectricityPack;
import universalelectricity.core.item.IItemElectric;
import universalelectricity.core.vector.Vector3;
@ -21,6 +20,8 @@ import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import cofh.api.energy.IEnergyContainerItem;
import cofh.api.energy.IEnergyHandler;
/**
* A universal electricity tile used for tiles that consume or produce electricity.
@ -31,7 +32,7 @@ import buildcraft.api.power.PowerHandler.Type;
* @author micdoodle8, Calclavia
*
*/
public abstract class TileEntityUniversalElectrical extends TileEntityElectrical implements IEnergySink, IEnergySource, IPowerReceptor
public abstract class TileEntityUniversalElectrical extends TileEntityElectrical implements IEnergySink, IEnergySource, IPowerReceptor, IEnergyHandler
{
protected boolean isAddedToEnergyNet;
public PowerHandler bcPowerHandler;
@ -58,10 +59,10 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
energy = manager.charge(itemStack, (int) (energy * Compatibility.TO_IC2_RATIO), 0, false, false) * Compatibility.IC2_RATIO;
this.provideElectricity(energy, true);
}
else if (itemStack.getItem() instanceof IChargeableItem)
else if (itemStack.getItem() instanceof IEnergyContainerItem)
{
float accepted = ((IChargeableItem) itemStack.getItem()).receiveEnergy(itemStack, this.getProvide(ForgeDirection.UNKNOWN) * Compatibility.BC3_RATIO, true);
this.provideElectricity(accepted, true);
float forgienEnergyAccepted = ((IEnergyContainerItem) itemStack.getItem()).receiveEnergy(itemStack, (int) (this.getProvide(ForgeDirection.UNKNOWN) * Compatibility.TO_TE_RATIO), false);
this.provideElectricity(forgienEnergyAccepted * Compatibility.TE_RATIO, true);
}
}
}
@ -90,10 +91,10 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
this.receiveElectricity(energy, true);
}
}
else if (itemStack.getItem() instanceof IChargeableItem)
else if (itemStack.getItem() instanceof IEnergyContainerItem)
{
float given = ((IChargeableItem) itemStack.getItem()).transferEnergy(itemStack, this.getRequest(ForgeDirection.UNKNOWN) * Compatibility.BC3_RATIO, true);
this.receiveElectricity(given, true);
float forgienEnergy = ((IEnergyContainerItem) itemStack.getItem()).extractEnergy(itemStack, (int) (this.getRequest(ForgeDirection.UNKNOWN) * Compatibility.TO_TE_RATIO), false);
this.receiveElectricity(forgienEnergy * Compatibility.TE_RATIO, true);
}
}
}
@ -148,7 +149,10 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
{
if (!this.produceUE(outputDirection))
{
this.produceBuildCraft(outputDirection);
if (!this.produceThermalExpansion(outputDirection))
{
this.produceBuildCraft(outputDirection);
}
}
}
@ -156,6 +160,37 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
}
}
public boolean produceThermalExpansion(ForgeDirection outputDirection)
{
if (!this.worldObj.isRemote && outputDirection != null && outputDirection != ForgeDirection.UNKNOWN)
{
float provide = this.getProvide(outputDirection);
if (this.getEnergyStored() >= provide && provide > 0)
{
if (Compatibility.isThermalExpansionLoaded())
{
TileEntity tileEntity = new Vector3(this).modifyPositionFromSide(outputDirection).getTileEntity(this.worldObj);
if (tileEntity instanceof IEnergyHandler)
{
IEnergyHandler receiver = (IEnergyHandler) tileEntity;
int convertedProvide = (int) (provide * Compatibility.TO_TE_RATIO);
if (receiver.canInterface(outputDirection.getOpposite()) && receiver.receiveEnergy(outputDirection.getOpposite(), convertedProvide, true) > 0)
{
int forgienEnergyUsed = receiver.receiveEnergy(outputDirection.getOpposite(), convertedProvide, false);
this.provideElectricity(forgienEnergyUsed * Compatibility.TE_RATIO, true);
return true;
}
}
}
}
}
return false;
}
public boolean produceBuildCraft(ForgeDirection outputDirection)
{
if (!this.worldObj.isRemote && outputDirection != null && outputDirection != ForgeDirection.UNKNOWN)
@ -176,13 +211,12 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
{
if (receiver.powerRequest() > 0)
{
float bc3Provide = provide * Compatibility.TO_BC_RATIO;
float energyUsed = Math.min(receiver.receiveEnergy(this.bcBlockType, bc3Provide, outputDirection.getOpposite()), bc3Provide);
this.provideElectricity(energyUsed * Compatibility.TO_BC_RATIO, true);
float convertedProvide = provide * Compatibility.TO_BC_RATIO;
float forgienEnergyUsed = receiver.receiveEnergy(this.bcBlockType, convertedProvide, outputDirection.getOpposite());
this.provideElectricity(forgienEnergyUsed * Compatibility.BC3_RATIO, true);
return true;
}
}
return true;
}
}
}
@ -191,6 +225,40 @@ public abstract class TileEntityUniversalElectrical extends TileEntityElectrical
return false;
}
/**
* TE Methods
*/
public int receiveEnergy(ForgeDirection from, int maxReceive, boolean simulate)
{
return (int) (this.receiveElectricity(from, ElectricityPack.getFromWatts(maxReceive * Compatibility.TE_RATIO, this.getVoltage()), !simulate) * Compatibility.TO_TE_RATIO);
}
public int extractEnergy(ForgeDirection from, int maxExtract, boolean simulate)
{
return (int) (this.provideElectricity(from, ElectricityPack.getFromWatts(maxExtract * Compatibility.TE_RATIO, this.getVoltage()), !simulate).getWatts() * Compatibility.TO_TE_RATIO);
}
public boolean canInterface(ForgeDirection from)
{
return this.canConnect(from);
}
/**
* Returns the amount of energy currently stored.
*/
public int getEnergyStored(ForgeDirection from)
{
return (int) (this.getEnergyStored() * Compatibility.TO_TE_RATIO);
}
/**
* Returns the maximum amount of energy that can be stored.
*/
public int getMaxEnergyStored(ForgeDirection from)
{
return (int) (this.getMaxEnergyStored() * Compatibility.TO_TE_RATIO);
}
/**
* IC2 Methods
*/

View file

@ -5,6 +5,7 @@ import ic2.api.energy.tile.IEnergySink;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
@ -28,6 +29,7 @@ import universalelectricity.core.vector.VectorHelper;
import buildcraft.api.power.IPowerReceptor;
import buildcraft.api.power.PowerHandler.PowerReceiver;
import buildcraft.api.power.PowerHandler.Type;
import cofh.api.energy.IEnergyHandler;
import cpw.mods.fml.common.FMLLog;
/**
@ -63,7 +65,7 @@ public class UniversalNetwork extends ElectricityNetwork
if (totalEnergyRequest > 0)
{
boolean markRefresh = false;
for (TileEntity tileEntity : avaliableEnergyTiles)
{
if (tileEntity != null && !tileEntity.isInvalid())
@ -102,7 +104,7 @@ public class UniversalNetwork extends ElectricityNetwork
if (energyToSend > 0)
{
remainingUsableEnergy -= electricalTile.injectEnergyUnits(direction, energyToSend * Compatibility.TO_IC2_RATIO);
remainingUsableEnergy -= electricalTile.injectEnergyUnits(direction, energyToSend * Compatibility.TO_IC2_RATIO) * Compatibility.IC2_RATIO;
}
}
}
@ -120,11 +122,33 @@ public class UniversalNetwork extends ElectricityNetwork
{
if (this.getConductors().contains(conductor))
{
float energyToSend = totalUsableEnergy * ((receiver.powerRequest() * Compatibility.TO_BC_RATIO) / totalEnergyRequest);
float energyToSend = totalUsableEnergy * ((receiver.powerRequest() * Compatibility.BC3_RATIO) / totalEnergyRequest);
if (energyToSend > 0)
{
remainingUsableEnergy -= receiver.receiveEnergy(Type.PIPE, energyToSend * Compatibility.TO_BC_RATIO, direction);
remainingUsableEnergy -= receiver.receiveEnergy(Type.PIPE, energyToSend * Compatibility.TO_BC_RATIO, direction) * Compatibility.BC3_RATIO;
}
}
}
}
}
else if (Compatibility.isThermalExpansionLoaded() && tileEntity instanceof IEnergyHandler)
{
IEnergyHandler receiver = (IEnergyHandler) tileEntity;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity conductor = VectorHelper.getConnectorFromSide(tileEntity.worldObj, new Vector3(tileEntity), direction);
if (receiver.canInterface(direction))
{
if (this.getConductors().contains(conductor))
{
float energyToSend = totalUsableEnergy * ((receiver.receiveEnergy(direction, (int) (remainingUsableEnergy * Compatibility.TO_TE_RATIO), true) * Compatibility.TE_RATIO) / totalEnergyRequest);
if (energyToSend > 0)
{
remainingUsableEnergy -= receiver.receiveEnergy(direction, (int) (energyToSend * Compatibility.TO_TE_RATIO), false) * Compatibility.TE_RATIO;
}
}
}
@ -137,8 +161,8 @@ public class UniversalNetwork extends ElectricityNetwork
markRefresh = true;
}
}
if(markRefresh)
if (markRefresh)
{
this.refresh();
}
@ -154,7 +178,7 @@ public class UniversalNetwork extends ElectricityNetwork
{
List<ElectricityPack> requests = new ArrayList<ElectricityPack>();
Iterator<TileEntity> it = this.getAcceptors().iterator();
Iterator<TileEntity> it = new HashSet(this.getAcceptors()).iterator();
while (it.hasNext())
{
@ -188,7 +212,7 @@ public class UniversalNetwork extends ElectricityNetwork
if (((IEnergySink) tileEntity).acceptsEnergyFrom(VectorHelper.getTileEntityFromSide(tileEntity.worldObj, new Vector3(tileEntity), direction), direction) && this.getConductors().contains(VectorHelper.getConnectorFromSide(tileEntity.worldObj, new Vector3(tileEntity), direction)))
{
ElectricityPack pack = ElectricityPack.getFromWatts((float) (((IEnergySink) tileEntity).demandedEnergyUnits() * Compatibility.IC2_RATIO), 1);
if (pack.getWatts() > 0)
{
requests.add(pack);
@ -216,7 +240,29 @@ public class UniversalNetwork extends ElectricityNetwork
}
continue;
}
if (Compatibility.isThermalExpansionLoaded() && tileEntity instanceof IEnergyHandler)
{
IEnergyHandler receiver = (IEnergyHandler) tileEntity;
for (ForgeDirection direction : ForgeDirection.VALID_DIRECTIONS)
{
TileEntity conductor = VectorHelper.getConnectorFromSide(tileEntity.worldObj, new Vector3(tileEntity), direction);
if (receiver.canInterface(direction))
{
ElectricityPack pack = ElectricityPack.getFromWatts(receiver.receiveEnergy(direction, (int) Integer.MAX_VALUE, true) * Compatibility.TE_RATIO, 1);
if (pack.getWatts() > 0)
{
requests.add(pack);
break;
}
}
}
continue;
}
}
}

View file

@ -62,32 +62,32 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
if (provide > 0)
{
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
if (outputNetwork != null)
{
ElectricityPack powerRequest = outputNetwork.getRequest(this);
TileEntity outputTile = VectorHelper.getConnectorFromSide(this.worldObj, new Vector3(this), outputDirection);
IElectricityNetwork outputNetwork = ElectricityHelper.getNetworkFromTileEntity(outputTile, outputDirection);
if (outputNetwork != null)
{
ElectricityPack powerRequest = outputNetwork.getRequest(this);
if (powerRequest.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()), ElectricityPack.getFromWatts(provide, this.getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, this);
this.provideElectricity(sendPack.getWatts() - rejectedPower, true);
return true;
}
}
else if (outputTile instanceof IElectrical)
{
float requestedEnergy = ((IElectrical) outputTile).getRequest(outputDirection.getOpposite());
if (requestedEnergy > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()), ElectricityPack.getFromWatts(provide, this.getVoltage()));
float acceptedEnergy = ((IElectrical) outputTile).receiveElectricity(outputDirection.getOpposite(), sendPack, true);
this.setEnergyStored(this.getEnergyStored() - acceptedEnergy);
return true;
}
}
if (powerRequest.getWatts() > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()), ElectricityPack.getFromWatts(provide, this.getVoltage()));
float rejectedPower = outputNetwork.produce(sendPack, this);
this.provideElectricity(Math.max(sendPack.getWatts() - rejectedPower, 0), true);
return true;
}
}
else if (outputTile instanceof IElectrical)
{
float requestedEnergy = ((IElectrical) outputTile).getRequest(outputDirection.getOpposite());
if (requestedEnergy > 0)
{
ElectricityPack sendPack = ElectricityPack.min(ElectricityPack.getFromWatts(this.getEnergyStored(), this.getVoltage()), ElectricityPack.getFromWatts(provide, this.getVoltage()));
float acceptedEnergy = ((IElectrical) outputTile).receiveElectricity(outputDirection.getOpposite(), sendPack, true);
this.provideElectricity(acceptedEnergy, true);
return true;
}
}
}
}
@ -121,6 +121,11 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
{
if (this.getInputDirections().contains(from))
{
if (!doReceive)
{
return this.getRequest(from);
}
return this.receiveElectricity(receive, doReceive);
}
@ -132,6 +137,11 @@ public abstract class TileEntityElectrical extends TileEntityAdvanced implements
{
if (this.getOutputDirections().contains(from))
{
if (!doProvide)
{
return ElectricityPack.getFromWatts(this.getProvide(from), this.getVoltage());
}
return this.provideElectricity(request, doProvide);
}