From 291b7fcd68b0924ffdd4d77268c2f30a64227c7b Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Fri, 24 Feb 2023 01:01:17 +0800 Subject: [PATCH 1/3] feature: Add config button for reservedCrafting MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit reservedCrafting即合成时总会给各配方物品保留一个格子以方便连续合成的吸取. --- .../java/fi/dy/masa/itemscroller/config/Configs.java | 2 ++ .../dy/masa/itemscroller/event/KeybindCallbacks.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/main/java/fi/dy/masa/itemscroller/config/Configs.java b/src/main/java/fi/dy/masa/itemscroller/config/Configs.java index ef47b87d9..e2a29e9a9 100644 --- a/src/main/java/fi/dy/masa/itemscroller/config/Configs.java +++ b/src/main/java/fi/dy/masa/itemscroller/config/Configs.java @@ -65,6 +65,7 @@ public static class Generic public static class Toggles { public static final ConfigBoolean CRAFTING_FEATURES = new ConfigBoolean("enableCraftingFeatures", true, "Enables scrolling items to and from crafting grids,\nwith a built-in 18 recipe memory.\nHold down the Recipe key to see the stored recipes and\nto change the selection. While holding the Recipe key,\nyou can either scroll or press a number key to change the selection.\nA recipe is stored to the currently selected \"recipe slot\"\n by clicking pick block over a configured crafting output slot.\nThe supported crafting grids must be added to the scrollableCraftingGrids list."); + public static final ConfigBoolean RESERVED_CRAFTING = new ConfigBoolean("enableReservedCrafting", false, "Enables to reserve slots of items of recipes in inventory,\nso items on the ground could be picked up for further crafting"); public static final ConfigBoolean DROP_MATCHING = new ConfigBoolean("enableDropkeyDropMatching", true, "Enables dropping all matching items from the same\ninventory with the hotkey"); public static final ConfigBoolean RIGHT_CLICK_CRAFT_STACK = new ConfigBoolean("enableRightClickCraftingOneStack", true, "Enables crafting up to one full stack when right clicking on\na slot that has been configured as a crafting output slot."); public static final ConfigBoolean SCROLL_EVERYTHING = new ConfigBoolean("enableScrollingEverything", true, "Enables scroll moving all items at once while\nholding the modifierMoveEverything keybind"); @@ -79,6 +80,7 @@ public static class Toggles public static final ImmutableList OPTIONS = ImmutableList.of( CRAFTING_FEATURES, + RESERVED_CRAFTING, DROP_MATCHING, RIGHT_CLICK_CRAFT_STACK, SCROLL_EVERYTHING, diff --git a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java index 85d5c218b..1d8dfd159 100644 --- a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java +++ b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java @@ -193,9 +193,14 @@ public void onClientTick(MinecraftClient mc) int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe); if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible // System.out.println("recipe"); - int option = InventoryUtils.checkRecipeEnough(recipe, gui); - if(option > 0) { - mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, option > 1); + if(Configs.Toggles.RESERVED_CRAFTING.getBooleanValue()) { + int option = InventoryUtils.checkRecipeEnough(recipe, gui); + if (option > 0) { + mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, option > 1); + } + } + else{ + mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, true); } } else { From faba65cd30f8572b6afce6763974810f5a39bd3b Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Fri, 24 Feb 2023 01:03:06 +0800 Subject: [PATCH 2/3] feature: craftEveryThing is now available for stonecutter --- .../java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java index 1d8dfd159..d0d23a1ca 100644 --- a/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java +++ b/src/main/java/fi/dy/masa/itemscroller/event/KeybindCallbacks.java @@ -190,7 +190,6 @@ public void onClientTick(MinecraftClient mc) RecipePattern recipe = RecipeStorage.getInstance().getSelectedRecipe(); CraftingRecipe bookRecipe = InventoryUtils.getBookRecipeFromPattern(recipe); - int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe); if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible // System.out.println("recipe"); if(Configs.Toggles.RESERVED_CRAFTING.getBooleanValue()) { @@ -205,6 +204,7 @@ public void onClientTick(MinecraftClient mc) } else { InventoryUtils.tryMoveItemsToFirstCraftingGrid(recipe, gui, true); + int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe); if(stonecuttingRecipeIndex != -1 && gui instanceof StonecutterScreen) { mc.interactionManager.clickButton((gui.getScreenHandler()).syncId, stonecuttingRecipeIndex); } From 12156018b583e64725ed1192f0cf42da9ed52451 Mon Sep 17 00:00:00 2001 From: wendavid552 Date: Fri, 24 Feb 2023 01:05:04 +0800 Subject: [PATCH 3/3] perf: move attempts to search for recipes of stonecutters into more specific conditions --- .../java/fi/dy/masa/itemscroller/util/InventoryUtils.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java b/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java index 508d37762..6291804d6 100644 --- a/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java +++ b/src/main/java/fi/dy/masa/itemscroller/util/InventoryUtils.java @@ -1377,7 +1377,7 @@ public static void craftEverythingPossibleWithCurrentRecipe(RecipePattern recipe String cacheName = null; for (int i = 0; i < 36; i++) { CraftingRecipe bookRecipe = getBookRecipeFromPattern(recipe); - if (bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible + if (!(gui instanceof StonecutterScreen) && bookRecipe != null && !bookRecipe.isIgnoredInRecipeBook()) { // Use recipe book if possible MinecraftClient mc = MinecraftClient.getInstance(); mc.interactionManager.clickRecipe(gui.getScreenHandler().syncId, bookRecipe, true); } else { @@ -1390,6 +1390,12 @@ public static void craftEverythingPossibleWithCurrentRecipe(RecipePattern recipe } tryMoveItemsToCraftingGridSlots(recipe, slot, gui, true); + + int stonecuttingRecipeIndex = InventoryUtils.getStonecuttingRecipeFromPattern(recipe); + if(stonecuttingRecipeIndex != -1 && gui instanceof StonecutterScreen) { + MinecraftClient mc = MinecraftClient.getInstance(); + mc.interactionManager.clickButton((gui.getScreenHandler()).syncId, stonecuttingRecipeIndex); + } } if(!StringUtils.isBlank(cacheName) && gui instanceof AnvilScreen) { ((IMixinAnvilScreen)gui).itemscroller_setItemName(cacheName);