From 0a20b53c6d1800aa8a0c3ea8d8a26189f6714c08 Mon Sep 17 00:00:00 2001 From: asiekierka Date: Sat, 21 Mar 2015 20:01:01 +0100 Subject: [PATCH] add RF power support to Auto Workbenches --- buildcraft_resources/changelog/7.0.0 | 1 + .../buildcraft/factory/TileAutoWorkbench.java | 34 ++++++++++++++++--- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/buildcraft_resources/changelog/7.0.0 b/buildcraft_resources/changelog/7.0.0 index 9801fbf5..2e15aa13 100644 --- a/buildcraft_resources/changelog/7.0.0 +++ b/buildcraft_resources/changelog/7.0.0 @@ -5,6 +5,7 @@ Additions: * Blueprint Library renamed to Electronic Library, supports copying books - and soon other things! (asie) * Rewritten Zone Planner map system - should have much less lag and take up less disk space! * **Note** - all existing zone planner previews will disappear. To reload them, simply break and place the zone planner! + * You can now apply RF power (or a redstone engine) to an Auto Workbench to speed it up (asie - thanks KingTriaxx!) * Items: * Paintbrush for dyeing pipes and other supported blocks (asie) * Debugger for developer use (asie) diff --git a/common/buildcraft/factory/TileAutoWorkbench.java b/common/buildcraft/factory/TileAutoWorkbench.java index 80785291..e273d5f0 100644 --- a/common/buildcraft/factory/TileAutoWorkbench.java +++ b/common/buildcraft/factory/TileAutoWorkbench.java @@ -24,7 +24,9 @@ import net.minecraft.world.WorldServer; import net.minecraftforge.common.util.ForgeDirection; import buildcraft.api.core.IInvSlot; +import buildcraft.api.power.IRedstoneEngineReceiver; import buildcraft.api.tiles.IHasWork; +import buildcraft.core.lib.RFBattery; import buildcraft.core.lib.block.TileBuildCraft; import buildcraft.core.lib.inventory.InvUtils; import buildcraft.core.lib.inventory.InventoryConcatenator; @@ -35,7 +37,7 @@ import buildcraft.core.proxy.CoreProxy; import buildcraft.core.lib.utils.CraftingUtils; import buildcraft.core.lib.utils.Utils; -public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory, IHasWork { +public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory, IHasWork, IRedstoneEngineReceiver { public static final int SLOT_RESULT = 0; public static final int CRAFT_TIME = 256; @@ -65,11 +67,21 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory private IRecipe currentRecipe; private boolean hasWork = false; + public TileAutoWorkbench() { + super(); + this.setBattery(new RFBattery(16, 16, 0)); + } + @Override public boolean hasWork() { return !isJammed && hasWork; } + @Override + public boolean canConnectRedstoneEngine(ForgeDirection side) { + return true; + } + private class LocalInventoryCrafting extends InventoryCrafting { public LocalInventoryCrafting() { @@ -244,10 +256,24 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory return; } - update++; - if (update % UPDATE_TIME == 0) { - updateCrafting(); + int updatesLeft = getBattery().getEnergyStored() + 1; + + while (updatesLeft > 0) { + update++; + + if (update % UPDATE_TIME == 0) { + updateCrafting(); + + if (isJammed || !hasWork || resultInv.getStackInSlot(SLOT_RESULT) != null) { + progress = 0; + break; + } + } + + updatesLeft--; + } + getBattery().setEnergy(0); } public int getProgressScaled(int i) {