diff --git a/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java b/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java index 0ac09cb8b..f240b3868 100644 --- a/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java +++ b/src/minecraft/dark/library/machine/TileEntityRunnableMachine.java @@ -1,23 +1,27 @@ package dark.library.machine; +import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.oredict.OreDictionary; import calclavia.lib.TileEntityUniversalRunnable; import dark.library.PowerSystems; public class TileEntityRunnableMachine extends TileEntityUniversalRunnable { - /** The amount of players using the console. */ - public int playersUsing = 0; + public static String powerToggleItemID = "battery"; + + protected boolean runPowerless = false; @Override public void updateEntity() { - super.updateEntity(); - - if (this.wattsReceived < this.getWattBuffer() && PowerSystems.runPowerLess(PowerSystems.INDUSTRIALCRAFT, PowerSystems.BUILDCRAFT, PowerSystems.MEKANISM)) + /* CREATES FREE POWER IF NO POWER PROVIDER IS FOUND OR BLOCK WAS SET TO RUN WITHOUT POWER */ + if (this.wattsReceived < this.getWattBuffer() && (this.runPowerless || PowerSystems.runPowerLess(PowerSystems.INDUSTRIALCRAFT, PowerSystems.BUILDCRAFT, PowerSystems.MEKANISM))) { this.wattsReceived += Math.max(this.getWattBuffer() - this.wattsReceived, 0); } + + super.updateEntity(); } @Override @@ -25,6 +29,7 @@ public class TileEntityRunnableMachine extends TileEntityUniversalRunnable { super.readFromNBT(nbt); this.wattsReceived = nbt.getDouble("wattsReceived"); + this.runPowerless = nbt.getBoolean("shouldPower"); } @Override @@ -32,5 +37,21 @@ public class TileEntityRunnableMachine extends TileEntityUniversalRunnable { super.writeToNBT(nbt); nbt.setDouble("wattsReceived", this.wattsReceived); + nbt.setBoolean("shouldPower", this.runPowerless); + } + + /** + * Sets this machine to run without power only if the given stack match an ore directory name + */ + public void toggleInfPower(ItemStack item) + { + for (ItemStack stack : OreDictionary.getOres(this.powerToggleItemID)) + { + if (stack.isItemEqual(item)) + { + this.runPowerless = !this.runPowerless; + break; + } + } } }