diff --git a/src/generated/resources/.cache/cache b/src/generated/resources/.cache/cache index d95296e43..61ce819ce 100644 --- a/src/generated/resources/.cache/cache +++ b/src/generated/resources/.cache/cache @@ -273,7 +273,7 @@ b7829c2ef2c47188713f8cab21b2c9bc7f9c5b79 assets\create\blockstates\portable_stor e8b0a401c10d1ba67ed71ba31bd5f9bc28571b65 assets\create\blockstates\powered_toggle_latch.json 3a739f9d4276828d83f2d2750bf3227c87bcd438 assets\create\blockstates\pulley_magnet.json 469e430d96cb0a5e1aaf6b7cc5d401d488c9e600 assets\create\blockstates\pulse_repeater.json -5c1df061eb5efe49beee7219e113206fc31a4733 assets\create\blockstates\radial_chassis.json +5d1b30c2bab556f57c78e7780fd445b08f541a50 assets\create\blockstates\radial_chassis.json 8929677f2cc5354aa19ef182af69f9f0b41eb242 assets\create\blockstates\redstone_contact.json c29213b77ac0c78d8979c5f6188d2b265696f9b9 assets\create\blockstates\redstone_link.json e2990fe70ad5d10437a376e70e167d1856277cc1 assets\create\blockstates\rope.json @@ -325,7 +325,7 @@ c77b46d8b459e5c7cc495393546f3fcca8a1fa1d assets\create\blockstates\weathered_lim 7f39521b211441f5c3e06d60c5978cebe16cacfb assets\create\blockstates\zinc_block.json b7181bcd8182b2f17088e5aa881f374c9c65470c assets\create\blockstates\zinc_ore.json 4311c87a21caccb97b693bf914c8ce79de3f814b assets\create\lang\en_ud.json -f7cd2198ffae7a8dea1902b242aa56110ca28885 assets\create\lang\en_us.json +076a6cd28a3c1020cf0080a5107718576eeb13e1 assets\create\lang\en_us.json 846200eb548d3bfa2e77b41039de159b4b6cfb45 assets\create\models\block\acacia_window.json 1930fa3a3c98d53dd19e4ee7f55bc27fd47aa281 assets\create\models\block\acacia_window_pane_noside.json 1763ea2c9b981d187f5031ba608f3d5d3be3986a assets\create\models\block\acacia_window_pane_noside_alt.json diff --git a/src/generated/resources/assets/create/blockstates/radial_chassis.json b/src/generated/resources/assets/create/blockstates/radial_chassis.json index d60327a8a..04e5c08ae 100644 --- a/src/generated/resources/assets/create/blockstates/radial_chassis.json +++ b/src/generated/resources/assets/create/blockstates/radial_chassis.json @@ -29,8 +29,8 @@ }, { "when": { - "sticky_south": "true", - "axis": "x" + "axis": "x", + "sticky_south": "true" }, "apply": { "model": "create:block/radial_chassis_side_x_sticky", @@ -39,8 +39,8 @@ }, { "when": { - "sticky_south": "true", - "axis": "y" + "axis": "y", + "sticky_south": "true" }, "apply": { "model": "create:block/radial_chassis_side_y_sticky" @@ -48,8 +48,8 @@ }, { "when": { - "sticky_south": "true", - "axis": "z" + "axis": "z", + "sticky_south": "true" }, "apply": { "model": "create:block/radial_chassis_side_x_sticky", @@ -59,8 +59,8 @@ }, { "when": { - "sticky_south": "false", - "axis": "x" + "axis": "x", + "sticky_south": "false" }, "apply": { "model": "create:block/radial_chassis_side_x", @@ -69,8 +69,8 @@ }, { "when": { - "sticky_south": "false", - "axis": "y" + "axis": "y", + "sticky_south": "false" }, "apply": { "model": "create:block/radial_chassis_side_y" @@ -78,8 +78,8 @@ }, { "when": { - "sticky_south": "false", - "axis": "z" + "axis": "z", + "sticky_south": "false" }, "apply": { "model": "create:block/radial_chassis_side_x", @@ -89,8 +89,8 @@ }, { "when": { - "sticky_west": "true", - "axis": "x" + "axis": "x", + "sticky_west": "true" }, "apply": { "model": "create:block/radial_chassis_side_x_sticky", @@ -99,8 +99,8 @@ }, { "when": { - "sticky_west": "true", - "axis": "y" + "axis": "y", + "sticky_west": "true" }, "apply": { "model": "create:block/radial_chassis_side_y_sticky", @@ -109,8 +109,8 @@ }, { "when": { - "sticky_west": "true", - "axis": "z" + "axis": "z", + "sticky_west": "true" }, "apply": { "model": "create:block/radial_chassis_side_z_sticky", @@ -119,8 +119,8 @@ }, { "when": { - "sticky_west": "false", - "axis": "x" + "axis": "x", + "sticky_west": "false" }, "apply": { "model": "create:block/radial_chassis_side_x", @@ -129,8 +129,8 @@ }, { "when": { - "sticky_west": "false", - "axis": "y" + "axis": "y", + "sticky_west": "false" }, "apply": { "model": "create:block/radial_chassis_side_y", @@ -139,8 +139,8 @@ }, { "when": { - "sticky_west": "false", - "axis": "z" + "axis": "z", + "sticky_west": "false" }, "apply": { "model": "create:block/radial_chassis_side_z", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index a346019d6..514e65a52 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -1047,6 +1047,8 @@ "block.create.mechanical_crafter.tooltip.summary": "A kinetic assembler for _automating_ any _shaped_ _crafting_ recipe. Place _multiple_ _in_ _a_ _grid_ corresponding to your recipe, and _arrange_ _their_ _belts_ to create a _flow_ that exits the grid on one of the crafters.", "block.create.mechanical_crafter.tooltip.condition1": "When Rotated", "block.create.mechanical_crafter.tooltip.behaviour1": "_Starts_ _the_ _crafting_ _process_ as soon as _all_ _crafters_ in the grid have been _given_ _an_ _item_.", + "block.create.mechanical_crafter.tooltip.condition2": "On Redstone Pulse", + "block.create.mechanical_crafter.tooltip.behaviour2": "_Forces_ the start of the _crafting_ _process_ with all currently given _items_ in the grid.", "block.create.mechanical_crafter.tooltip.control1": "When Wrenched at Front", "block.create.mechanical_crafter.tooltip.action1": "_Cycles_ _the_ _direction_ an individual crafter _moves_ _its_ _items_ towards. To form a working grid, _arrange_ _the_ _belts_ _in_ _a_ _flow_ which moves all items towards a final crafter. The final crafter must _point_ _away_ from the grid.", "block.create.mechanical_crafter.tooltip.control2": "When Wrenched at back", diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java index dd65147d7..65e0cd38d 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/MechanicalCrafterTileEntity.java @@ -63,10 +63,12 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { return stack; return super.insertItem(slot, stack, simulate); }; + + protected void onContentsChanged(int slot) { if (!getStackInSlot(slot).isEmpty() && phase == Phase.IDLE) - checkCompletedRecipe(); + checkCompletedRecipe(false); markDirty(); sendData(); }; @@ -80,6 +82,7 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { protected Phase phase; protected int countDown; protected boolean covered; + private boolean wasPoweredBefore = true; protected GroupedItems groupedItemsBeforeCraft; // for rendering on client private InsertingBehaviour inserting; @@ -198,11 +201,20 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { } @Override - public void tick() { + public void tick() { super.tick(); if (phase == Phase.ACCEPTING) return; + + if(wasPoweredBefore != world.isBlockPowered(pos)) { + wasPoweredBefore = world.isBlockPowered(pos); + if(wasPoweredBefore) { + if (world.isRemote) + return; + checkCompletedRecipe(true); + } + } if (phase == Phase.ASSEMBLING) { countDown -= getCountDownSpeed(); @@ -321,7 +333,6 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { tryInsert(); return; } - } protected boolean isTargetingBelt() { @@ -405,23 +416,26 @@ public class MechanicalCrafterTileEntity extends KineticTileEntity { if (world.isRemote) return; if (phase == Phase.IDLE && craftingItemPresent()) - checkCompletedRecipe(); + checkCompletedRecipe(false); if (phase == Phase.INSERTING) tryInsert(); } public boolean craftingItemPresent() { - return !inventory.getStackInSlot(0) - .isEmpty() || covered; + return !inventory.getStackInSlot(0).isEmpty(); + } + + public boolean craftingItemOrCoverPresent() { + return !inventory.getStackInSlot(0).isEmpty() || covered; } - protected void checkCompletedRecipe() { + protected void checkCompletedRecipe(boolean poweredStart) { if (getSpeed() == 0) return; if (world.isRemote) return; List chain = - RecipeGridHandler.getAllCraftersOfChainIf(this, MechanicalCrafterTileEntity::craftingItemPresent); + RecipeGridHandler.getAllCraftersOfChainIf(this, poweredStart ? MechanicalCrafterTileEntity::craftingItemPresent : MechanicalCrafterTileEntity::craftingItemOrCoverPresent, poweredStart); if (chain == null) return; chain.forEach(MechanicalCrafterTileEntity::begin); diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java index 830086716..185b51b34 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/crafter/RecipeGridHandler.java @@ -33,21 +33,38 @@ public class RecipeGridHandler { public static List getAllCraftersOfChain(MechanicalCrafterTileEntity root) { return getAllCraftersOfChainIf(root, Predicates.alwaysTrue()); } + + public static List getAllCraftersOfChainIf(MechanicalCrafterTileEntity root, + Predicate test){ + return getAllCraftersOfChainIf(root, test, false); + } + public static List getAllCraftersOfChainIf(MechanicalCrafterTileEntity root, - Predicate test) { + Predicate test, boolean poweredStart) { List crafters = new ArrayList<>(); List> frontier = new ArrayList<>(); Set visited = new HashSet<>(); frontier.add(Pair.of(root, null)); + + boolean powered = false; + boolean empty = false; + boolean allEmpty = true; while (!frontier.isEmpty()) { Pair pair = frontier.remove(0); MechanicalCrafterTileEntity current = pair.getKey(); MechanicalCrafterTileEntity last = pair.getValue(); - if (visited.contains(current) || !test.test(current)) + if (visited.contains(current)) return null; + if(!(test.test(current))) + empty = true; + else + allEmpty = false; + if(poweredStart && current.getWorld().isBlockPowered(current.getPos())) + powered = true; + crafters.add(current); visited.add(current); @@ -59,7 +76,7 @@ public class RecipeGridHandler { frontier.add(Pair.of(preceding, current)); } - return crafters; + return empty && ! powered || allEmpty ? null : crafters; } public static MechanicalCrafterTileEntity getTargetingCrafter(MechanicalCrafterTileEntity crafter) { diff --git a/src/main/resources/assets/create/lang/default/tooltips.json b/src/main/resources/assets/create/lang/default/tooltips.json index 12ab06055..b6ab00759 100644 --- a/src/main/resources/assets/create/lang/default/tooltips.json +++ b/src/main/resources/assets/create/lang/default/tooltips.json @@ -223,6 +223,8 @@ "block.create.mechanical_crafter.tooltip.summary": "A kinetic assembler for _automating_ any _shaped_ _crafting_ recipe. Place _multiple_ _in_ _a_ _grid_ corresponding to your recipe, and _arrange_ _their_ _belts_ to create a _flow_ that exits the grid on one of the crafters.", "block.create.mechanical_crafter.tooltip.condition1": "When Rotated", "block.create.mechanical_crafter.tooltip.behaviour1": "_Starts_ _the_ _crafting_ _process_ as soon as _all_ _crafters_ in the grid have been _given_ _an_ _item_.", + "block.create.mechanical_crafter.tooltip.condition2": "On Redstone Pulse", + "block.create.mechanical_crafter.tooltip.behaviour2": "_Forces_ the start of the _crafting_ _process_ with all currently given _items_ in the grid.", "block.create.mechanical_crafter.tooltip.control1": "When Wrenched at Front", "block.create.mechanical_crafter.tooltip.action1": "_Cycles_ _the_ _direction_ an individual crafter _moves_ _its_ _items_ towards. To form a working grid, _arrange_ _the_ _belts_ _in_ _a_ _flow_ which moves all items towards a final crafter. The final crafter must _point_ _away_ from the grid.", "block.create.mechanical_crafter.tooltip.control2": "When Wrenched at back",