Added "autocrafting mode" in Detector, fixes #329

To check if an item is being crafted. If no item is specified, it'll emit a signal if anything is crafting.
This commit is contained in:
Raoul Van den Berge
2016-09-13 01:54:43 +02:00
parent 5cb2aba719
commit f582aec94e
4 changed files with 31 additions and 4 deletions

View File

@@ -2,6 +2,7 @@
### 1.0.1
- Fixed advanced tooltips showing in Grid when not configured to do so (raoulvdberge)
- Added "autocrafting mode" in Detector, to check if an item is being crafted. If no item is specified, it'll emit a signal if anything is crafting (raoulvdberge)
### 1.0
**NOTE:** Due to the new crafting system, all Crafting Patterns made before 1.0 have to be re-made.

View File

@@ -27,6 +27,8 @@ public class SideButtonDetectorMode extends SideButton {
} else if (mode == TileDetector.MODE_ABOVE) {
mode = TileDetector.MODE_UNDER;
} else if (mode == TileDetector.MODE_UNDER) {
mode = TileDetector.MODE_AUTOCRAFTING;
} else if (mode == TileDetector.MODE_AUTOCRAFTING) {
mode = TileDetector.MODE_EQUAL;
}

View File

@@ -11,7 +11,9 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.items.IItemHandler;
import refinedstorage.RefinedStorage;
import refinedstorage.RefinedStorageBlocks;
import refinedstorage.api.autocrafting.task.ICraftingTask;
import refinedstorage.api.network.INetworkMaster;
import refinedstorage.api.storage.CompareUtils;
import refinedstorage.gui.GuiDetector;
import refinedstorage.inventory.ItemHandlerBasic;
import refinedstorage.inventory.ItemHandlerFluid;
@@ -34,7 +36,7 @@ public class TileDetector extends TileNode implements IComparable, IType {
}, new ITileDataConsumer<Integer, TileDetector>() {
@Override
public void setValue(TileDetector tile, Integer value) {
if (value == MODE_UNDER || value == MODE_EQUAL || value == MODE_ABOVE) {
if (value == MODE_UNDER || value == MODE_EQUAL || value == MODE_ABOVE || value == MODE_AUTOCRAFTING) {
tile.mode = value;
tile.markDirty();
@@ -69,6 +71,7 @@ public class TileDetector extends TileNode implements IComparable, IType {
public static final int MODE_UNDER = 0;
public static final int MODE_EQUAL = 1;
public static final int MODE_ABOVE = 2;
public static final int MODE_AUTOCRAFTING = 3;
private static final String NBT_COMPARE = "Compare";
private static final String NBT_MODE = "Mode";
@@ -106,11 +109,31 @@ public class TileDetector extends TileNode implements IComparable, IType {
ItemStack slot = itemFilters.getStackInSlot(0);
if (slot != null) {
if (mode == MODE_AUTOCRAFTING) {
boolean found = false;
for (ICraftingTask task : network.getCraftingTasks()) {
for (ItemStack output : task.getPattern().getOutputs()) {
if (CompareUtils.compareStackNoQuantity(slot, output)) {
found = true;
break;
}
}
if (found) {
break;
}
}
powered = found;
} else {
ItemStack stack = network.getItemStorage().get(slot, compare);
powered = isPowered(stack == null ? null : stack.stackSize);
}
} else {
powered = false;
powered = mode == MODE_AUTOCRAFTING && !network.getCraftingTasks().isEmpty();
}
} else if (type == IType.FLUIDS) {
FluidStack slot = fluidFilters.getFluids()[0];

View File

@@ -102,6 +102,7 @@ sidebutton.refinedstorage:detector.mode=Mode
sidebutton.refinedstorage:detector.mode.0=Emit signal when under the amount
sidebutton.refinedstorage:detector.mode.1=Emit signal when on the amount
sidebutton.refinedstorage:detector.mode.2=Emit signal when above the amount
sidebutton.refinedstorage:detector.mode.3=Emit signal when is autocrafting
block.refinedstorage:controller.0.name=Controller
block.refinedstorage:controller.1.name=Creative Controller