From 6f8a9199178339733d43a69ac59660b140be7eb4 Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Mon, 25 Nov 2024 18:35:17 +0100 Subject: [PATCH] Autocraft a better life - lang entries for panel auto-crafting - Mechanical crafters waste less time on empty animation frames - panel auto-crafting centres its recipes --- .../2d64935085b86659cb7857bad9701dbf9bab6e4c | 6 +- .../resources/assets/create/lang/en_ud.json | 6 +- .../resources/assets/create/lang/en_us.json | 6 +- .../crafter/MechanicalCrafterBlockEntity.java | 13 ++-- .../kinetics/crafter/RecipeGridHandler.java | 7 ++ .../factoryBoard/FactoryPanelScreen.java | 67 ++++++++++++------- .../assets/create/lang/default/interface.json | 6 +- 7 files changed, 77 insertions(+), 34 deletions(-) diff --git a/src/generated/resources/.cache/2d64935085b86659cb7857bad9701dbf9bab6e4c b/src/generated/resources/.cache/2d64935085b86659cb7857bad9701dbf9bab6e4c index da29cb5a51..950b672860 100644 --- a/src/generated/resources/.cache/2d64935085b86659cb7857bad9701dbf9bab6e4c +++ b/src/generated/resources/.cache/2d64935085b86659cb7857bad9701dbf9bab6e4c @@ -1,4 +1,4 @@ -// 1.20.1 2024-11-05T22:14:55.5235978 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)] +// 1.20.1 2024-11-25T18:00:08.2851015 Registrate Provider for create [Recipes, Advancements, Loot Tables, Tags (blocks), Tags (items), Tags (fluids), Tags (entity_types), Blockstates, Item models, Lang (en_us/en_ud)] 60bbdf92d2ac9824ea6144955c74043a6005f79d assets/create/blockstates/acacia_window.json 6a67703c2697d81b7dc83e9d72a66f9c9ff08383 assets/create/blockstates/acacia_window_pane.json c3ae87b62e81d8e9476eccd793bb1548d74c66a1 assets/create/blockstates/adjustable_chain_gearshift.json @@ -638,8 +638,8 @@ b0d8f08968763a5f74e5cd5644377a76a9f39753 assets/create/blockstates/yellow_toolbo fe8c497aacc641c2f01cec90bba9f19e59cc2ed2 assets/create/blockstates/yellow_valve_handle.json e819e93fdcbe9fd9c050a052d2718ff3b3539365 assets/create/blockstates/zinc_block.json 64121dcb216381c83b4fe28aa361ea07c24c9ad0 assets/create/blockstates/zinc_ore.json -57831942f845db5cd15c5ad08d643b25eaf5d6e1 assets/create/lang/en_ud.json -0f661f60a043ebcf20c52ad99e928d97cb0cd355 assets/create/lang/en_us.json +553a69a3cfe418452f126632905c039e89d3f47a assets/create/lang/en_ud.json +084c76dda84efc8a2a4c82615a0e411444e53afc assets/create/lang/en_us.json a97e1060e00ae701a02e39cd4ef8054cf345fac4 assets/create/models/block/acacia_window.json 103e032c0b1a0a6a27c67da8c91179a564bd281c assets/create/models/block/acacia_window_pane_noside.json fb00b627abda76ad4fea867ca57dbfadd24fffa3 assets/create/models/block/acacia_window_pane_noside_alt.json diff --git a/src/generated/resources/assets/create/lang/en_ud.json b/src/generated/resources/assets/create/lang/en_ud.json index 280c346555..86b1eb8c30 100644 --- a/src/generated/resources/assets/create/lang/en_ud.json +++ b/src/generated/resources/assets/create/lang/en_ud.json @@ -1191,9 +1191,13 @@ "create.gui.config.overlay8": "uoıʇısod ʇןnɐɟǝp ǝɥʇ oʇ ʇǝsǝɹ oʇ", "create.gui.contraptions.network_overstressed": "˙‾ʇɔɐdɯı‾ ‾ssǝɹʇs‾ ɥbıɥ ɐ ɥʇıʍ sʇuǝuodɯoɔ ǝɥʇ ‾uʍop‾ ‾ʍoןs‾ ɹo sǝɔɹnos ǝɹoɯ ppⱯ ˙‾pǝssǝɹʇsɹǝʌo‾ sı uoıʇdɐɹʇuoɔ sıɥʇ ʇɐɥʇ sɹɐǝddɐ ʇI", "create.gui.contraptions.not_fast_enough": "˙‾pǝǝds‾ ‾ɥbnouǝ‾ ɥʇıʍ buıʇɐʇoɹ ‾ʇou‾ sı %1$s sıɥʇ ʇɐɥʇ sɹɐǝddɐ ʇI", + "create.gui.factory_panel.activate_crafting": "buıʇɟɐɹƆ pǝbuɐɹɹɐ-ǝɹd ǝןbbo⟘", "create.gui.factory_panel.connect_input": "ןǝuɐd ʇnduı uɐ ʇɔǝuuoƆ", + "create.gui.factory_panel.crafting_input": "sʇuǝıpǝɹbuI pǝbɐʞɔɐԀ", + "create.gui.factory_panel.crafting_input_tip": "pǝʇɔǝuuoɔ oʇuı ǝbɐʞɔɐdu∩", + "create.gui.factory_panel.crafting_input_tip_1": ")ƐxƐ( sɹǝʇɟɐɹɔ ןɐɔıuɐɥɔǝɯ", "create.gui.factory_panel.empty_panel": "ןǝuɐd ʎʇdɯƎ", - "create.gui.factory_panel.expected_output": "%1$s ʇɔǝdxƎ", + "create.gui.factory_panel.expected_output": "%1$s buıʇɔǝdxƎ", "create.gui.factory_panel.expected_output_tip": "buıuɹnʇǝɹ ʇndʇno ɟo ʇunoɯɐ ǝɥ⟘", "create.gui.factory_panel.expected_output_tip_1": "ʇsǝnbǝɹ ןnɟssǝɔɔns ɥɔɐǝ ɹǝʇɟɐ", "create.gui.factory_panel.expected_output_tip_2": "ǝbuɐɥɔ oʇ ןןoɹɔS", diff --git a/src/generated/resources/assets/create/lang/en_us.json b/src/generated/resources/assets/create/lang/en_us.json index c77cec505d..551a28dcdb 100644 --- a/src/generated/resources/assets/create/lang/en_us.json +++ b/src/generated/resources/assets/create/lang/en_us.json @@ -1191,9 +1191,13 @@ "create.gui.config.overlay8": "to reset to the default position", "create.gui.contraptions.network_overstressed": "It appears that this contraption is _overstressed_. Add more sources or _slow_ _down_ the components with a high _stress_ _impact_.", "create.gui.contraptions.not_fast_enough": "It appears that this %1$s is _not_ rotating with _enough_ _speed_.", + "create.gui.factory_panel.activate_crafting": "Toggle pre-arranged Crafting", "create.gui.factory_panel.connect_input": "Connect an input panel", + "create.gui.factory_panel.crafting_input": "Packaged Ingredients", + "create.gui.factory_panel.crafting_input_tip": "Unpackage into connected", + "create.gui.factory_panel.crafting_input_tip_1": "mechanical crafters (3x3)", "create.gui.factory_panel.empty_panel": "Empty panel", - "create.gui.factory_panel.expected_output": "Expect %1$s", + "create.gui.factory_panel.expected_output": "Expecting %1$s", "create.gui.factory_panel.expected_output_tip": "The amount of output returning", "create.gui.factory_panel.expected_output_tip_1": "after each successful request", "create.gui.factory_panel.expected_output_tip_2": "Scroll to change", diff --git a/src/main/java/com/simibubi/create/content/kinetics/crafter/MechanicalCrafterBlockEntity.java b/src/main/java/com/simibubi/create/content/kinetics/crafter/MechanicalCrafterBlockEntity.java index 79fe8b3d6a..4dac8c256b 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crafter/MechanicalCrafterBlockEntity.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crafter/MechanicalCrafterBlockEntity.java @@ -203,6 +203,8 @@ public class MechanicalCrafterBlockEntity extends KineticBlockEntity { if (phaseBefore != phase && phase == Phase.CRAFTING) groupedItemsBeforeCraft = before; if (phaseBefore == Phase.EXPORTING && phase == Phase.WAITING) { + if (before.onlyEmptyItems()) + return; Direction facing = getBlockState().getValue(MechanicalCrafterBlock.HORIZONTAL_FACING); Vec3 vec = Vec3.atLowerCornerOf(facing.getNormal()) .scale(.75) @@ -253,7 +255,7 @@ public class MechanicalCrafterBlockEntity extends KineticBlockEntity { return; if (RecipeGridHandler.getTargetingCrafter(this) != null) { phase = Phase.EXPORTING; - countDown = 1000; + countDown = groupedItems.onlyEmptyItems() ? 0 : 1000; sendData(); return; } @@ -305,12 +307,15 @@ public class MechanicalCrafterBlockEntity extends KineticBlockEntity { return; } + boolean empty = groupedItems.onlyEmptyItems(); Pointing pointing = getBlockState().getValue(MechanicalCrafterBlock.POINTING); groupedItems.mergeOnto(targetingCrafter.groupedItems, pointing); groupedItems = new GroupedItems(); float pitch = targetingCrafter.groupedItems.grid.size() * 1 / 16f + .5f; - AllSoundEvents.CRAFTER_CLICK.playOnServer(level, worldPosition, 1, pitch); + + if (!empty) + AllSoundEvents.CRAFTER_CLICK.playOnServer(level, worldPosition, 1, pitch); phase = Phase.WAITING; countDown = 0; @@ -497,7 +502,7 @@ public class MechanicalCrafterBlockEntity extends KineticBlockEntity { if (RecipeGridHandler.getPrecedingCrafters(this) .isEmpty()) { phase = Phase.ASSEMBLING; - countDown = 500; + countDown = 1; } sendData(); } @@ -514,7 +519,7 @@ public class MechanicalCrafterBlockEntity extends KineticBlockEntity { return; phase = Phase.ASSEMBLING; - countDown = Math.max(100, getCountDownSpeed() + 1); + countDown = 1; } @Override diff --git a/src/main/java/com/simibubi/create/content/kinetics/crafter/RecipeGridHandler.java b/src/main/java/com/simibubi/create/content/kinetics/crafter/RecipeGridHandler.java index 8ff15ae150..2dd08289b0 100644 --- a/src/main/java/com/simibubi/create/content/kinetics/crafter/RecipeGridHandler.java +++ b/src/main/java/com/simibubi/create/content/kinetics/crafter/RecipeGridHandler.java @@ -239,6 +239,13 @@ public class RecipeGridHandler { height = maxY - minY + 1; } + public boolean onlyEmptyItems() { + for (ItemStack stack : grid.values()) + if (!stack.isEmpty()) + return false; + return true; + } + } } diff --git a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java index 8f1b2b4731..0bb098795a 100644 --- a/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java +++ b/src/main/java/com/simibubi/create/content/logistics/factoryBoard/FactoryPanelScreen.java @@ -91,14 +91,23 @@ public class FactoryPanelScreen extends AbstractSimiScreen { } craftingIngredients = new ArrayList<>(); - - int width = 3; - if (availableCraftingRecipe instanceof IShapedRecipe shaped) - width = shaped.getRecipeWidth(); - NonNullList ingredients = availableCraftingRecipe.getIngredients(); BigItemStack emptyIngredient = new BigItemStack(ItemStack.EMPTY, 1); + int width = Math.min(3, ingredients.size()); + int height = Math.min(3, ingredients.size() / 3 + 1); + + if (availableCraftingRecipe instanceof IShapedRecipe shaped) { + width = shaped.getRecipeWidth(); + height = shaped.getRecipeHeight(); + } + + if (height == 1) + for (int i = 0; i < 3; i++) + craftingIngredients.add(emptyIngredient); + if (width == 1) + craftingIngredients.add(emptyIngredient); + for (int i = 0; i < ingredients.size(); i++) { Ingredient ingredient = ingredients.get(i); BigItemStack craftingIngredient = emptyIngredient; @@ -257,24 +266,23 @@ public class FactoryPanelScreen extends AbstractSimiScreen { if (mouseX >= outputX - 1 && mouseX < outputX - 1 + 18 && mouseY >= outputY - 1 && mouseY < outputY - 1 + 18) { - graphics.renderComponentTooltip(font, - List.of( - CreateLang - .translate("gui.factory_panel.expected_output", CreateLang.itemName(outputConfig.stack) - .add(CreateLang.text(" x" + outputConfig.count)) - .string()) - .color(ScrollInput.HEADER_RGB) - .component(), - CreateLang.translate("gui.factory_panel.expected_output_tip") - .style(ChatFormatting.GRAY) - .component(), - CreateLang.translate("gui.factory_panel.expected_output_tip_1") - .style(ChatFormatting.GRAY) - .component(), - CreateLang.translate("gui.factory_panel.expected_output_tip_2") - .style(ChatFormatting.DARK_GRAY) - .style(ChatFormatting.ITALIC) - .component()), + MutableComponent c1 = CreateLang + .translate("gui.factory_panel.expected_output", CreateLang.itemName(outputConfig.stack) + .add(CreateLang.text(" x" + outputConfig.count)) + .string()) + .color(ScrollInput.HEADER_RGB) + .component(); + MutableComponent c2 = CreateLang.translate("gui.factory_panel.expected_output_tip") + .style(ChatFormatting.GRAY) + .component(); + MutableComponent c3 = CreateLang.translate("gui.factory_panel.expected_output_tip_1") + .style(ChatFormatting.GRAY) + .component(); + MutableComponent c4 = CreateLang.translate("gui.factory_panel.expected_output_tip_2") + .style(ChatFormatting.DARK_GRAY) + .style(ChatFormatting.ITALIC) + .component(); + graphics.renderComponentTooltip(font, craftingActive ? List.of(c1, c2, c3) : List.of(c1, c2, c3, c4), mouseX, mouseY); } } @@ -383,8 +391,19 @@ public class FactoryPanelScreen extends AbstractSimiScreen { if (mouseX < inputX - 1 || mouseX >= inputX - 1 + 18 || mouseY < inputY - 1 || mouseY >= inputY - 1 + 18) return; - if (craftingActive) + if (craftingActive) { + graphics.renderComponentTooltip(font, List.of(CreateLang.translate("gui.factory_panel.crafting_input") + .color(ScrollInput.HEADER_RGB) + .component(), + CreateLang.translate("gui.factory_panel.crafting_input_tip") + .style(ChatFormatting.GRAY) + .component(), + CreateLang.translate("gui.factory_panel.crafting_input_tip_1") + .style(ChatFormatting.GRAY) + .component()), + mouseX, mouseY); return; + } if (itemStack.stack.isEmpty()) { graphics.renderComponentTooltip(font, List.of(CreateLang.translate("gui.factory_panel.empty_panel") diff --git a/src/main/resources/assets/create/lang/default/interface.json b/src/main/resources/assets/create/lang/default/interface.json index d611db67f9..8fc0e3ccf5 100644 --- a/src/main/resources/assets/create/lang/default/interface.json +++ b/src/main/resources/assets/create/lang/default/interface.json @@ -1036,7 +1036,7 @@ "create.gui.factory_panel.left_click_reset": "Left-Click to reset", "create.gui.factory_panel.promises_expire_title": "Promises expire after", "create.gui.factory_panel.promises_do_not_expire": "Promises do not expire", - "create.gui.factory_panel.expected_output": "Expect %1$s", + "create.gui.factory_panel.expected_output": "Expecting %1$s", "create.gui.factory_panel.restocker_promises_tip": "When items are sent, a promise", "create.gui.factory_panel.restocker_promises_tip_1": "is held until they arrive.", "create.gui.factory_panel.recipe_promises_tip": "When inputs are sent, a promise", @@ -1062,6 +1062,10 @@ "create.gui.factory_panel.restocker_address_given": "Sending to", "create.gui.factory_panel.restocker_address_tip": "Enter an address that will", "create.gui.factory_panel.restocker_address_tip_1": "cause packages to arrive here.", + "create.gui.factory_panel.activate_crafting": "Toggle pre-arranged Crafting", + "create.gui.factory_panel.crafting_input": "Packaged Ingredients", + "create.gui.factory_panel.crafting_input_tip": "Unpackage into connected", + "create.gui.factory_panel.crafting_input_tip_1": "mechanical crafters (3x3)", "create.gui.redstone_requester.allow_partial": "Allow partial orders", "create.gui.redstone_requester.dont_allow_partial": "Must send all items",