Skip to content

Commit

Permalink
add RF power support to Auto Workbenches
Browse files Browse the repository at this point in the history
  • Loading branch information
asiekierka committed Mar 21, 2015
1 parent bcb2a40 commit 0a20b53
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions buildcraft_resources/changelog/7.0.0
Expand Up @@ -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)
Expand Down
34 changes: 30 additions & 4 deletions common/buildcraft/factory/TileAutoWorkbench.java
Expand Up @@ -24,7 +24,9 @@
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;
Expand All @@ -35,7 +37,7 @@
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;
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -244,10 +256,24 @@ public void updateEntity() {
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) {
Expand Down

0 comments on commit 0a20b53

Please sign in to comment.