add RF power support to Auto Workbenches
This commit is contained in:
parent
bcb2a40fa5
commit
0a20b53c6d
2 changed files with 31 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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,12 +256,26 @@ public class TileAutoWorkbench extends TileBuildCraft implements ISidedInventory
|
|||
return;
|
||||
}
|
||||
|
||||
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) {
|
||||
return (progress * i) / CRAFT_TIME;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue