From e4faaaa2cf8ef3192556b8fba41c599eb76107e4 Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Tue, 3 Dec 2024 00:34:24 +0000 Subject: [PATCH 01/24] Update 1.18 RELEASE_HASH --- .release-info/1.18/RELEASE_HASH | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/RELEASE_HASH b/.release-info/1.18/RELEASE_HASH index 13ff471..440757a 100644 --- a/.release-info/1.18/RELEASE_HASH +++ b/.release-info/1.18/RELEASE_HASH @@ -1 +1 @@ -3f7a5625360952bcbd99e42b635469bff7a7f01c +256510bbbd810366ee9da94fc0ddd31d450e4576 From 682696c1d0473f237064013137ecaaa8b7bc5936 Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Tue, 3 Dec 2024 00:34:24 +0000 Subject: [PATCH 02/24] Reset 1.18 changelog --- CHANGELOG/1.18/0.1.9.md | 5 +++++ CHANGELOG/1.18/current.md | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 CHANGELOG/1.18/0.1.9.md diff --git a/CHANGELOG/1.18/0.1.9.md b/CHANGELOG/1.18/0.1.9.md new file mode 100644 index 0000000..b20232c --- /dev/null +++ b/CHANGELOG/1.18/0.1.9.md @@ -0,0 +1,5 @@ +# 0.1.9 + +- `[FIX]` Fix endless loop when calculating recipes +- `[FIX]` Fixes to recipe cost calculations +- `[FIX]` Miscellaneous optimizations diff --git a/CHANGELOG/1.18/current.md b/CHANGELOG/1.18/current.md index 97305b4..e69de29 100644 --- a/CHANGELOG/1.18/current.md +++ b/CHANGELOG/1.18/current.md @@ -1,3 +0,0 @@ -- `[FIX]` Fix endless loop when calculating recipes -- `[FIX]` Fixes to recipe cost calculations -- `[FIX]` Miscellaneous optimizations From 2f82d5880755188fa736692f4fba7132747a5183 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:39:24 -0800 Subject: [PATCH 03/24] Changed text for queue sections --- .../assets/crafttracker/lang/de_de.json | 8 +++---- .../assets/crafttracker/lang/en_gb.json | 14 +++++------ .../assets/crafttracker/lang/en_us.json | 14 +++++------ .../crafttracker/data/CTLangProvider.java | 24 +++++++++---------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/src/generated/resources/assets/crafttracker/lang/de_de.json b/src/generated/resources/assets/crafttracker/lang/de_de.json index ea551eb..9bf89e8 100644 --- a/src/generated/resources/assets/crafttracker/lang/de_de.json +++ b/src/generated/resources/assets/crafttracker/lang/de_de.json @@ -17,10 +17,10 @@ "crafttracker.msg.shopping_list_overlay_mode.show": "Nun wird das Overlay mit der Einkaufsliste angezeigt.", "crafttracker.screen.craft_queue.empty_message": "Die Warteschlange ist leer.", "crafttracker.screen.craft_queue.help_message": "Die Warteschlange verwalten:", - "crafttracker.screen.craft_queue.section.fuel": "Kraftstoff", - "crafttracker.screen.craft_queue.section.intermediates": "Zwischenprodukte", - "crafttracker.screen.craft_queue.section.materials": "Materialien", - "crafttracker.screen.craft_queue.section.products": "Produkte", + "crafttracker.screen.craft_queue.section.fuel": "Und dieser Treibstoff:", + "crafttracker.screen.craft_queue.section.intermediates": "Sie m\u00FCssen zun\u00E4chst Folgendes tun:", + "crafttracker.screen.craft_queue.section.materials": "Mit diesen Materialien:", + "crafttracker.screen.craft_queue.section.products": "Um zu machen:", "crafttracker.screen.craft_queue.title": "Herstellungswarteschlange", "crafttracker.screen.have": "habe %d", "crafttracker.screen.queue_mgr.button.clear": "Alle l\u00F6schen", diff --git a/src/generated/resources/assets/crafttracker/lang/en_gb.json b/src/generated/resources/assets/crafttracker/lang/en_gb.json index 34181ea..6cc48ee 100644 --- a/src/generated/resources/assets/crafttracker/lang/en_gb.json +++ b/src/generated/resources/assets/crafttracker/lang/en_gb.json @@ -9,18 +9,18 @@ "crafttracker.config.client.shopping_list_width": "The width of the shopping list overlay", "crafttracker.config.client.shopping_list_x": "The X position on the screen for the shopping list overlay", "crafttracker.config.client.shopping_list_y": "The Y position on the screen for the shopping list overlay", - "crafttracker.msg.queue_overlay_mode.dynamic": "The craft list overlay mode is dynamic.", - "crafttracker.msg.queue_overlay_mode.hide": "The craft list overlay will now be hidden.", - "crafttracker.msg.queue_overlay_mode.show": "The craft list overlay will now be shown.", + "crafttracker.msg.queue_overlay_mode.dynamic": "The craft queue overlay mode is dynamic.", + "crafttracker.msg.queue_overlay_mode.hide": "The craft queue overlay will now be hidden.", + "crafttracker.msg.queue_overlay_mode.show": "The craft queue overlay will now be shown.", "crafttracker.msg.shopping_list_overlay_mode.dynamic": "The shopping list overlay mode is dynamic.", "crafttracker.msg.shopping_list_overlay_mode.hide": "The shopping list overlay will now be hidden.", "crafttracker.msg.shopping_list_overlay_mode.show": "The shopping list overlay will now be shown.", "crafttracker.screen.craft_queue.empty_message": "The queue is empty.", "crafttracker.screen.craft_queue.help_message": "To manage the queue:", - "crafttracker.screen.craft_queue.section.fuel": "Fuel", - "crafttracker.screen.craft_queue.section.intermediates": "Intermediates", - "crafttracker.screen.craft_queue.section.materials": "Materials", - "crafttracker.screen.craft_queue.section.products": "Products", + "crafttracker.screen.craft_queue.section.fuel": "And this fuel:", + "crafttracker.screen.craft_queue.section.intermediates": "You first need to make:", + "crafttracker.screen.craft_queue.section.materials": "With these materials:", + "crafttracker.screen.craft_queue.section.products": "To make:", "crafttracker.screen.craft_queue.title": "Craft Queue", "crafttracker.screen.have": "have %d", "crafttracker.screen.queue_mgr.button.clear": "Clear", diff --git a/src/generated/resources/assets/crafttracker/lang/en_us.json b/src/generated/resources/assets/crafttracker/lang/en_us.json index 34181ea..6cc48ee 100644 --- a/src/generated/resources/assets/crafttracker/lang/en_us.json +++ b/src/generated/resources/assets/crafttracker/lang/en_us.json @@ -9,18 +9,18 @@ "crafttracker.config.client.shopping_list_width": "The width of the shopping list overlay", "crafttracker.config.client.shopping_list_x": "The X position on the screen for the shopping list overlay", "crafttracker.config.client.shopping_list_y": "The Y position on the screen for the shopping list overlay", - "crafttracker.msg.queue_overlay_mode.dynamic": "The craft list overlay mode is dynamic.", - "crafttracker.msg.queue_overlay_mode.hide": "The craft list overlay will now be hidden.", - "crafttracker.msg.queue_overlay_mode.show": "The craft list overlay will now be shown.", + "crafttracker.msg.queue_overlay_mode.dynamic": "The craft queue overlay mode is dynamic.", + "crafttracker.msg.queue_overlay_mode.hide": "The craft queue overlay will now be hidden.", + "crafttracker.msg.queue_overlay_mode.show": "The craft queue overlay will now be shown.", "crafttracker.msg.shopping_list_overlay_mode.dynamic": "The shopping list overlay mode is dynamic.", "crafttracker.msg.shopping_list_overlay_mode.hide": "The shopping list overlay will now be hidden.", "crafttracker.msg.shopping_list_overlay_mode.show": "The shopping list overlay will now be shown.", "crafttracker.screen.craft_queue.empty_message": "The queue is empty.", "crafttracker.screen.craft_queue.help_message": "To manage the queue:", - "crafttracker.screen.craft_queue.section.fuel": "Fuel", - "crafttracker.screen.craft_queue.section.intermediates": "Intermediates", - "crafttracker.screen.craft_queue.section.materials": "Materials", - "crafttracker.screen.craft_queue.section.products": "Products", + "crafttracker.screen.craft_queue.section.fuel": "And this fuel:", + "crafttracker.screen.craft_queue.section.intermediates": "You first need to make:", + "crafttracker.screen.craft_queue.section.materials": "With these materials:", + "crafttracker.screen.craft_queue.section.products": "To make:", "crafttracker.screen.craft_queue.title": "Craft Queue", "crafttracker.screen.have": "have %d", "crafttracker.screen.queue_mgr.button.clear": "Clear", diff --git a/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java b/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java index 2493c69..c7c4069 100644 --- a/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java +++ b/src/main/java/com/sweetrpg/crafttracker/data/CTLangProvider.java @@ -33,10 +33,10 @@ private void processENUS() { add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_TITLE, "Craft Queue"); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_EMPTY, "The queue is empty."); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_HELP, "To manage the queue:"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "Products"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "Intermediates"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "Materials"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "Fuel"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "To make:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "You first need to make:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "With these materials:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "And this fuel:"); add(Constants.TRANSLATION_KEY_GUI_HAVE, "have %d"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_TITLE, "Shopping List"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_EMPTY, "The shopping list is empty."); @@ -78,10 +78,10 @@ private void processENGB() { add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_TITLE, "Craft Queue"); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_EMPTY, "The queue is empty."); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_HELP, "To manage the queue:"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "Products"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "Intermediates"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "Materials"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "Fuel"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "To make:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "You first need to make:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "With these materials:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "And this fuel:"); add(Constants.TRANSLATION_KEY_GUI_HAVE, "have %d"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_TITLE, "Shopping List"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_EMPTY, "The shopping list is empty."); @@ -123,10 +123,10 @@ private void processDEDE() { add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_TITLE, "Herstellungswarteschlange"); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_EMPTY, "Die Warteschlange ist leer."); add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_HELP, "Die Warteschlange verwalten:"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "Produkte"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "Zwischenprodukte"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "Materialien"); - add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "Kraftstoff"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_PRODUCTS, "Um zu machen:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_INTERMEDIATES, "Sie müssen zunächst Folgendes tun:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_MATERIALS, "Mit diesen Materialien:"); + add(Constants.TRANSLATION_KEY_GUI_CRAFT_QUEUE_SECTION_FUEL, "Und dieser Treibstoff:"); add(Constants.TRANSLATION_KEY_GUI_HAVE, "habe %d"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_TITLE, "Einkaufsliste"); add(Constants.TRANSLATION_KEY_GUI_SHOPPING_LIST_EMPTY, "The shopping list is empty."); From 8809e0f9d5d2e104ad76391fda842e872b86e506 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:39:57 -0800 Subject: [PATCH 04/24] Increased processing depth --- .../crafttracker/common/manager/CraftingQueueManager.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index 7293161..086c4a1 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -34,7 +34,7 @@ public class CraftingQueueManager { public static CraftingQueueManager INSTANCE = new CraftingQueueManager(); - private static final int MAX_PROCESSING_LEVEL = 2; + private static final int MAX_PROCESSING_LEVEL = 3; private Map endProducts = new HashMap<>(); private Map intermediateProducts = new HashMap<>(); From fdacc6af4487547dca12192a16c1aac830f45f7c Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:40:44 -0800 Subject: [PATCH 05/24] Fixed namespace check to include result item Changed order of conditional arguments to take advantage of short-circuiting --- .../common/manager/CraftingQueueManager.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index 086c4a1..b28a9c8 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -284,6 +284,17 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { var ingredients = recipe.getIngredients(); CraftTracker.LOGGER.debug("ingredients: {}", ingredients.stream().map(DebugUtil::printIngredient).toList()); + // if the ingredients are in a different namespace than the recipe, and we're not at the root, treat the recipe + var recipeNamespace = ObjectUtils.defaultIfNull(recipe.getId().getNamespace(), ""); + var itemNamespace = ObjectUtils.defaultIfNull(recipe.getResultItem().getItem().getRegistryName().getNamespace(), ""); + if(depth > 0 && + (!RecipeUtil.areIngredientsSameNamespace(recipeNamespace, ingredients) || + !RecipeUtil.areIngredientsSameNamespace(itemNamespace, ingredients))) { + CraftTracker.LOGGER.debug("ingredients for sub-recipe are not in the same namespace as the recipe: {}", + DebugUtil.printRecipe(recipe)); + return null; + } + // tally ingredients Map ingredientTally = new HashMap<>(); for(Ingredient ingredient : ingredients) { From e94de2eb6055063685a88a1649204535e1a38ce8 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:41:09 -0800 Subject: [PATCH 06/24] Handle computed sub-recipe null --- .../common/manager/CraftingQueueManager.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index b28a9c8..c5174e1 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -360,6 +360,19 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { ObjectUtils.defaultIfNull(quantity, 0) + needsQty); var computedSubRecipe = this.computeRecipe(chosenSubRecipe, amountRequired * iterations, depth + 1); + CraftTracker.LOGGER.debug("computedSubRecipe: {}", computedSubRecipe); + if(computedSubRecipe == null) { + CraftTracker.LOGGER.debug("computed sub-recipe for {} returned is null; treat as raw material", DebugUtil.printRecipe(chosenSubRecipe)); + // if the sub-recipe comes back null, then treat the result item as a raw material + computedRecipe.rawMaterials.compute(id, + (itemId, quantity) -> + ObjectUtils.defaultIfNull(quantity, 0) + (amountRequired * iterations)); + return; + } + + computedRecipe.intermediateProducts.compute(id, + (itemId, quantity) -> + ObjectUtils.defaultIfNull(quantity, 0) + needsQty); // merge subrecipe items into this CraftTracker.LOGGER.debug("merging subrecipe contents: {} into this: {}", computedSubRecipe, computedRecipe); From 43a691e5c180276b83b5d456e651b12e1da3c53a Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:41:20 -0800 Subject: [PATCH 07/24] Cleanup --- .../common/manager/CraftingQueueManager.java | 42 ------------------- 1 file changed, 42 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index c5174e1..77f9677 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -311,13 +311,10 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { } // process ingredients -// for(Ingredient ingredient : ingredients) { ingredientTally.forEach((ingredientId, ingredientAmount) -> { CraftTracker.LOGGER.debug("ingredient: id {}, amount {}", ingredientId, ingredientAmount); -// ItemStack chosenStack = RecipeUtil.chooseLeastExpensiveOf(ingredient.getItems()); Item item = ForgeRegistries.ITEMS.getValue(ingredientId); -// Item item = chosenStack.getItem(); CraftTracker.LOGGER.debug("item: {}", DebugUtil.printItem(item)); int amountRequired = ingredientAmount; // chosenStack.getCount(); CraftTracker.LOGGER.debug("amountRequired: {}", amountRequired); @@ -351,14 +348,8 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { CraftTracker.LOGGER.debug("subRecipes has {} items; ingredient {} is an intermediate product", subRecipes.size(), ingredientId); var chosenSubRecipe = RecipeUtil.chooseLeastExpensiveOf(subRecipes); -// CraftTracker.LOGGER.debug("least expensive item index: {}", subIndex); -// var chosenSubRecipe = subRecipes.get(subIndex); CraftTracker.LOGGER.debug("chosenSubRecipe: {}", DebugUtil.printRecipe(chosenSubRecipe)); - computedRecipe.intermediateProducts.compute(id, - (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, 0) + needsQty); - var computedSubRecipe = this.computeRecipe(chosenSubRecipe, amountRequired * iterations, depth + 1); CraftTracker.LOGGER.debug("computedSubRecipe: {}", computedSubRecipe); if(computedSubRecipe == null) { @@ -399,39 +390,6 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { return computedRecipe; } -// public static class ProductItem { -// private ResourceLocation itemId; -// private int iterations; -// private List categories; -// -// public ProductItem(ResourceLocation itemId, int iterations, List categories) { -// this.itemId = itemId; -// this.iterations = iterations; -// this.categories = categories; -// } -// -// public ResourceLocation getItemId() { -// return itemId; -// } -// -// public int getIterations() { -// return iterations; -// } -// -// public List getCategories() { -// return categories; -// } -// -// @Override -// public String toString() { -// return "ProductItem{" + -// "itemId=" + itemId + -// ", iterations=" + iterations + -// ", categories=" + categories + -// '}'; -// } -// } - public class QueueItem { private ResourceLocation itemId; private int quantity; From c5bb900692e3ecab0202fca07a1c1464c6b56633 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:41:41 -0800 Subject: [PATCH 08/24] Cost multiplication --- .../crafttracker/common/util/RecipeUtil.java | 54 ++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index a72811f..6c14fab 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -9,8 +9,10 @@ import net.minecraft.util.Tuple; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.crafting.CraftingRecipe; import net.minecraft.world.item.crafting.Ingredient; import net.minecraft.world.item.crafting.Recipe; +import org.apache.commons.lang3.ObjectUtils; import java.io.IOException; import java.util.*; @@ -18,6 +20,9 @@ public class RecipeUtil { + public static final float NON_VANILLA_COST_MULTIPLIER = 1.2f; + public static final float NON_CRAFTING_COST_MULTIPLIER = 1.25f; + private static Map ingredientCostsByTag = new HashMap<>(); private static Map ingredientCostOverrides = new HashMap<>(); @@ -80,12 +85,41 @@ public static boolean areIngredientsSame(NonNullList ingredients) { return ing.size() == 1; } + public static boolean areIngredientsSameNamespace(String namespace, NonNullList ingredients) { + CraftTracker.LOGGER.debug("RecipeUtil#areIngredientsSame: {}", ingredients.stream().map(DebugUtil::printIngredient).toList()); + + Set ing = ingredients.stream() + .map(i -> Arrays.asList(i.getItems())) + .filter(l -> !l.isEmpty()) + .map(l -> l.get(0)) + .map(i -> ObjectUtils.defaultIfNull(i.getItem().getRegistryName().getNamespace(), "")) + .filter(n -> n.equals(namespace)) + .collect(Collectors.toSet()); + + return ing.size() == 1; + } + public static int calculateRecipeCost(Recipe recipe) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: {}", DebugUtil.printRecipe(recipe)); - return recipe.getIngredients().stream() + int cost = recipe.getIngredients().stream() .map(RecipeUtil::calculateIngredientCost) .reduce(0, Integer::sum); + + // if the item's namespace is not 'minecraft:', increase the cost + if(!recipe.getId().getNamespace().equals("minecraft")) { + CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla recipe {} by {}", + cost, DebugUtil.printRecipe(recipe), NON_VANILLA_COST_MULTIPLIER); + cost *= NON_VANILLA_COST_MULTIPLIER; + } + + if(!(recipe instanceof CraftingRecipe)) { + CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-crafting table recipe {} by {}", + cost, DebugUtil.printRecipe(recipe), NON_CRAFTING_COST_MULTIPLIER); + cost *= NON_CRAFTING_COST_MULTIPLIER; + } + + return cost; } public static int calculateIngredientCost(Ingredient ingredient) { @@ -108,6 +142,15 @@ public static int calculateIngredientCost(Ingredient ingredient) { if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); var cost = ingredientCostsByTag.get(tagId) * count; + + // if the item's namespace is not 'minecraft:', increase the cost + if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && + !ObjectUtils.defaultIfNull(tagId.getNamespace(), "").equals("minecraft")) { + CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla item {} by {}", + cost, tagId, NON_VANILLA_COST_MULTIPLIER); + cost *= NON_VANILLA_COST_MULTIPLIER; + } + if(cost > highestCost) { highestCost = cost; } @@ -140,6 +183,15 @@ public static int calculateItemCost(ItemStack stack) { if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); var cost = ingredientCostsByTag.get(tagId) * count; + + // if the item's namespace is not 'minecraft:', increase the cost + if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && + !ObjectUtils.defaultIfNull(tagId.getNamespace(), "").equals("minecraft")) { + CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla item {} by {}", + cost, tagId, NON_VANILLA_COST_MULTIPLIER); + cost *= NON_VANILLA_COST_MULTIPLIER; + } + if(cost > highestCost) { highestCost = cost; } From e5e4b74949cef7a6a54d601ae98cf4581b14f319 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:41:48 -0800 Subject: [PATCH 09/24] Notes --- CHANGELOG/1.18/current.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG/1.18/current.md b/CHANGELOG/1.18/current.md index e69de29..b7821d5 100644 --- a/CHANGELOG/1.18/current.md +++ b/CHANGELOG/1.18/current.md @@ -0,0 +1,5 @@ +- `[FIX]` Made cost calculation of non-vanilla recipes slightly more expensive +- `[FIX]` Made cost calculation of non-crafting table recipes slightly more expensive +- `[FIX]` Increased recipe calculation depth to 3 +- `[FIX]` Added checks for recipe and ingredient namespaces in determining intermediate/raw status +- `[FIX]` Changed text for crafting queue sections From 5943bc45fc574b7d4fcc36713609999c5fc3b5f3 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 08:42:23 -0800 Subject: [PATCH 10/24] Ignore .idea directory --- .gitignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 2b0372c..2e64e8a 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ out *.ipr *.iws *.iml -.idea/workspace.xml +.idea/ # gradle build @@ -27,4 +27,4 @@ logs # Files from Forge MDK forge*changelog.txt /src/generated/resources/.cache/cache -.DS_Store \ No newline at end of file +.DS_Store From 79b6765bb9f34bcc65df6183ffae7be8edc55e65 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 09:02:43 -0800 Subject: [PATCH 11/24] Fix code scanning alert no. 7: Implicit narrowing conversion in compound assignment Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> Signed-off-by: Paul Schifferer --- .../java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index 6c14fab..da26134 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -182,7 +182,7 @@ public static int calculateItemCost(ItemStack stack) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); - var cost = ingredientCostsByTag.get(tagId) * count; + double cost = ingredientCostsByTag.get(tagId) * count; // if the item's namespace is not 'minecraft:', increase the cost if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && From 6cd0e6c7ee393b086d055eb8792f0e04ff35d32e Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 17:12:44 -0800 Subject: [PATCH 12/24] Checkpoint --- .../client/overlay/CraftQueueOverlay.java | 7 +++++ .../common/manager/CraftingQueueManager.java | 29 ++++++++++++------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java index 17fc2c1..50d70f3 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java @@ -37,7 +37,9 @@ public class CraftQueueOverlay { var mgr = CraftingQueueManager.INSTANCE; var products = mgr.getEndProducts().stream().sorted((i1, i2) -> { var item1 = ForgeRegistries.ITEMS.getValue(i1.getProductId()); + if(item1 == null) return 0; var item2 = ForgeRegistries.ITEMS.getValue(i2.getProductId()); + if(item2 == null) return 0; return item1.getDescription().getString().compareTo(item2.getDescription().getString()); }).toList(); @@ -103,6 +105,9 @@ public class CraftQueueOverlay { var p = products.get(i); var item = ForgeRegistries.ITEMS.getValue(p.getProductId()); + if(item == null) { + continue; + } var stack = item.getDefaultInstance(); var selectedRecipe = p.getRecipes().get(p.getIndex()); var amountProduced = selectedRecipe.getResultItem().getCount() * p.getIterations(); @@ -136,7 +141,9 @@ public class CraftQueueOverlay { // items var sortedIntermediates = mgr.getIntermediates().stream().sorted((i1, i2) -> { var item1 = ForgeRegistries.ITEMS.getValue(i1.getItemId()); + if(item1 == null) return 0; var item2 = ForgeRegistries.ITEMS.getValue(i2.getItemId()); + if(item2 == null) return 0; return item1.getDescription().getString().compareTo(item2.getDescription().getString()); }).toList(); for(int i = 0; i < sortedIntermediates.size(); i++) { diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index 7293161..0d87b94 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -28,7 +28,6 @@ import java.nio.file.StandardOpenOption; import java.text.MessageFormat; import java.util.*; -import java.util.stream.Collectors; public class CraftingQueueManager { @@ -96,31 +95,30 @@ public void save(Player player) { } public List getEndProducts() { - return endProducts.entrySet() + return endProducts.values() .stream() - .map(e -> e.getValue()) .toList(); } public List getIntermediates() { return intermediateProducts.entrySet() .stream() - .map(e -> new QueueItem(e.getKey(), e.getValue())) - .collect(Collectors.toUnmodifiableList()); + .map(e -> new QueueItem(e.getKey(), false, e.getValue())) + .toList(); } public List getRawMaterials() { return rawMaterials.entrySet() .stream() - .map(e -> new QueueItem(e.getKey(), e.getValue())) - .collect(Collectors.toUnmodifiableList()); + .map(e -> new QueueItem(e.getKey(), false, e.getValue())) + .toList(); } public List getFuel() { return fuel.entrySet() .stream() - .map(e -> new QueueItem(e.getKey(), e.getValue())) - .collect(Collectors.toUnmodifiableList()); + .map(e -> new QueueItem(e.getKey(), false, e.getValue())) + .toList(); } public void addProduct(Player player, ResourceLocation itemId, int quantity) { @@ -130,7 +128,7 @@ public void addProduct(Player player, ResourceLocation itemId, int quantity) { var recipes = RecipeUtil.getRecipesFor(itemId); - if(recipes.size() > 0) { + if(!recipes.isEmpty()) { CraftTracker.LOGGER.debug("recipes: {}", recipes.stream().map(DebugUtil::printRecipe)); var product = new CraftingQueueProduct(itemId, recipes, quantity); @@ -410,9 +408,10 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { public class QueueItem { private ResourceLocation itemId; + private boolean tag; private int quantity; - public QueueItem(ResourceLocation itemId, int quantity) { + public QueueItem(ResourceLocation itemId, boolean tag, int quantity) { this.itemId = itemId; this.quantity = quantity; } @@ -425,6 +424,14 @@ public void setItemId(ResourceLocation itemId) { this.itemId = itemId; } + public boolean isTag() { + return tag; + } + + public void setTag(boolean tag) { + this.tag = tag; + } + public int getQuantity() { return quantity; } From d7217f84c4640beb45cd61ba7e918f765b5b574b Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 17:15:05 -0800 Subject: [PATCH 13/24] Fix cast to int --- .../java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index da26134..b939f42 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -193,7 +193,7 @@ public static int calculateItemCost(ItemStack stack) { } if(cost > highestCost) { - highestCost = cost; + highestCost = (int) cost; } } } From ce26b95c0af8b09ae83e30a4799cace7d1d9375f Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 18:04:07 -0800 Subject: [PATCH 14/24] Use float instead --- .../crafttracker/common/util/RecipeUtil.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index b939f42..2b83411 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -99,12 +99,12 @@ public static boolean areIngredientsSameNamespace(String namespace, NonNullList< return ing.size() == 1; } - public static int calculateRecipeCost(Recipe recipe) { + public static float calculateRecipeCost(Recipe recipe) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: {}", DebugUtil.printRecipe(recipe)); - int cost = recipe.getIngredients().stream() + float cost = recipe.getIngredients().stream() .map(RecipeUtil::calculateIngredientCost) - .reduce(0, Integer::sum); + .reduce(0f, Float::sum); // if the item's namespace is not 'minecraft:', increase the cost if(!recipe.getId().getNamespace().equals("minecraft")) { @@ -122,7 +122,7 @@ public static int calculateRecipeCost(Recipe recipe) { return cost; } - public static int calculateIngredientCost(Ingredient ingredient) { + public static float calculateIngredientCost(Ingredient ingredient) { CraftTracker.LOGGER.debug("RecipeUtil#getIngredientCost: {}", DebugUtil.printIngredient(ingredient)); for(ItemStack stack : ingredient.getItems()) { @@ -136,7 +136,7 @@ public static int calculateIngredientCost(Ingredient ingredient) { } // it's not, so check its tags - int highestCost = 0; + float highestCost = 0; for(TagKey tag : stack.getTags().toList()) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { @@ -165,7 +165,7 @@ public static int calculateIngredientCost(Ingredient ingredient) { return 1; } - public static int calculateItemCost(ItemStack stack) { + public static float calculateItemCost(ItemStack stack) { CraftTracker.LOGGER.debug("#calculateItemCost: {}", DebugUtil.printItemStack(stack)); var itemId = stack.getItem().getRegistryName(); @@ -177,7 +177,7 @@ public static int calculateItemCost(ItemStack stack) { } // it's not, so check its tags - int highestCost = 0; + float highestCost = 0; for(TagKey tag : stack.getTags().toList()) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { @@ -213,7 +213,7 @@ public static Recipe chooseLeastExpensiveOf(List> recipes return recipes.get(0); } - List, Integer>> recipeCosts = new ArrayList<>(); + List, Float>> recipeCosts = new ArrayList<>(); for(Recipe recipe : recipes) { var cost = RecipeUtil.calculateRecipeCost(recipe); @@ -240,7 +240,7 @@ public static ItemStack chooseLeastExpensiveOf(ItemStack[] stacks) { return stacks[0]; } - List> itemCosts = new ArrayList<>(); + List> itemCosts = new ArrayList<>(); for(ItemStack stack : stacks) { var cost = RecipeUtil.calculateItemCost(stack); From f6f34e2b08be6b871196f118a0d49f0f9606945a Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 18:15:06 -0800 Subject: [PATCH 15/24] Just keep fixing --- .../java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index 2b83411..9a3ae43 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -141,7 +141,7 @@ public static float calculateIngredientCost(Ingredient ingredient) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); - var cost = ingredientCostsByTag.get(tagId) * count; + float cost = ingredientCostsByTag.get(tagId) * count; // if the item's namespace is not 'minecraft:', increase the cost if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && From 72172749224f12769618db13770d3811da3846c4 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 18:16:34 -0800 Subject: [PATCH 16/24] Logging --- .../java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index 9a3ae43..e573379 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -187,7 +187,7 @@ public static float calculateItemCost(ItemStack stack) { // if the item's namespace is not 'minecraft:', increase the cost if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && !ObjectUtils.defaultIfNull(tagId.getNamespace(), "").equals("minecraft")) { - CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla item {} by {}", + CraftTracker.LOGGER.debug("RecipeUtil#calculateItemCost: increasing cost ({}) of non-vanilla item {} by {}", cost, tagId, NON_VANILLA_COST_MULTIPLIER); cost *= NON_VANILLA_COST_MULTIPLIER; } From 8bc158d92348cba96e3d428a0b75b9747c42445e Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Wed, 4 Dec 2024 02:47:54 +0000 Subject: [PATCH 17/24] Update 1.18 VERSION file --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index 1a03094..9767cc9 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.1.9 +0.1.10 From 8b287574324ad622e211b4bfe02a3ecb2af6c800 Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 20:30:42 -0800 Subject: [PATCH 18/24] Tags --- .../client/event/ClientEventHandler.java | 4 +- .../client/overlay/CraftQueueOverlay.java | 30 +++-- .../common/manager/CraftingQueueManager.java | 116 +++++++++++++----- .../common/model/CraftingQueueItem.java | 45 +++++++ .../resources/META-INF/accesstransformer.cfg | 3 + 5 files changed, 152 insertions(+), 46 deletions(-) create mode 100644 src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java diff --git a/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java b/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java index 5c91a6c..01a002d 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/event/ClientEventHandler.java @@ -159,14 +159,14 @@ private static void handlePopulateShoppingList() { materials.forEach(m -> { var haveQty = InventoryUtil.getQuantityOf(player, m.getItemId()); - var needed = m.getQuantity() - haveQty; + var needed = m.getAmount() - haveQty; if(needed > 0) sMgr.addItem(player, m.getItemId(), needed); }); fuel.forEach(f -> { var haveQty = InventoryUtil.getQuantityOf(player, f.getItemId()); - var needed = f.getQuantity() - haveQty; + var needed = f.getAmount() - haveQty; if(needed > 0) sMgr.addItem(player, f.getItemId(), needed); diff --git a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java index 50d70f3..2bfce1f 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java @@ -151,10 +151,10 @@ public class CraftQueueOverlay { var item = ForgeRegistries.ITEMS.getValue(inter.getItemId()); var stack = item.getDefaultInstance(); - stack.setCount(inter.getQuantity()); + stack.setCount(inter.getAmount()); int playerHasQuantity = InventoryUtil.getQuantityOf(player, inter.getItemId()); - if(playerHasQuantity >= inter.getQuantity()) { + if(playerHasQuantity >= inter.getAmount()) { // don't need to display this intermediate, since the user doesn't need to make it continue; } @@ -166,14 +166,16 @@ public class CraftQueueOverlay { final int lambdaYpos = yPos; if(playerHasQuantity > 0) { var countText = I18n.get(Constants.TRANSLATION_KEY_GUI_HAVE, playerHasQuantity); - var text = String.format("%s [%s]", + var text = String.format("%s%s [%s]", item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3), + inter.isTag() ? "*" : "", countText); CraftTracker.LOGGER.trace("text: {}", text); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR); } else { - var text = item.getDescription().getString(MAX_STRING_LENGTH); + var text = item.getDescription().getString(MAX_STRING_LENGTH) + + (inter.isTag() ? "*" : ""); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, yPos + 4, TEXT_COLOR); } @@ -206,10 +208,10 @@ public class CraftQueueOverlay { var item = ForgeRegistries.ITEMS.getValue(m.getItemId()); var stack = item.getDefaultInstance(); - stack.setCount(m.getQuantity()); + stack.setCount(m.getAmount()); int playerHasQuantity = InventoryUtil.getQuantityOf(player, m.getItemId()); - if(playerHasQuantity >= m.getQuantity()) { + if(playerHasQuantity >= m.getAmount()) { // don't need to display this intermediate, since the user doesn't need to make it continue; } @@ -221,14 +223,16 @@ public class CraftQueueOverlay { final int lambdaYpos = yPos; if(playerHasQuantity > 0) { var countText = I18n.get(Constants.TRANSLATION_KEY_GUI_HAVE, playerHasQuantity); - var text = String.format("%s [%s]", + var text = String.format("%s%s [%s]", item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3), + m.isTag() ? "*" : "", countText); CraftTracker.LOGGER.trace("text: {}", text); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR); } else { - var text = item.getDescription().getString(MAX_STRING_LENGTH); + var text = item.getDescription().getString(MAX_STRING_LENGTH) + + (m.isTag() ? "*" : ""); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, yPos + 4, TEXT_COLOR); } @@ -261,10 +265,10 @@ public class CraftQueueOverlay { var item = ForgeRegistries.ITEMS.getValue(f.getItemId()); var stack = item.getDefaultInstance(); - stack.setCount(f.getQuantity()); + stack.setCount(f.getAmount()); int playerHasQuantity = InventoryUtil.getQuantityOf(player, f.getItemId()); - if(playerHasQuantity >= f.getQuantity()) { + if(playerHasQuantity >= f.getAmount()) { // don't need to display this intermediate, since the user doesn't need to make it continue; } @@ -276,14 +280,16 @@ public class CraftQueueOverlay { final int lambdaYpos = yPos; if(playerHasQuantity > 0) { var countText = I18n.get(Constants.TRANSLATION_KEY_GUI_HAVE, playerHasQuantity); - var text = String.format("%s [%s]", + var text = String.format("%s%s [%s]", item.getDescription().getString(MAX_STRING_LENGTH - countText.length() - 3), + f.isTag() ? "*" : "", countText); CraftTracker.LOGGER.trace("text: {}", text); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, lambdaYpos + 4, TEXT_COLOR); } else { - var text = item.getDescription().getString(MAX_STRING_LENGTH); + var text = item.getDescription().getString(MAX_STRING_LENGTH) + + (f.isTag() ? "*" : ""); GuiComponent.drawString(poseStack, gui.getFont(), text, x + ITEM_NAME_X_OFFSET, yPos + 4, TEXT_COLOR); } diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index 8b8cea2..b58bcd8 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -1,6 +1,7 @@ package com.sweetrpg.crafttracker.common.manager; import com.sweetrpg.crafttracker.CraftTracker; +import com.sweetrpg.crafttracker.common.model.CraftingQueueItem; import com.sweetrpg.crafttracker.common.model.CraftingQueueProduct; import com.sweetrpg.crafttracker.common.storage.CraftingQueueStorage; import com.sweetrpg.crafttracker.common.util.DebugUtil; @@ -11,6 +12,7 @@ import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.NbtIo; import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.Tuple; import net.minecraft.world.entity.player.Player; import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; @@ -33,12 +35,12 @@ public class CraftingQueueManager { public static CraftingQueueManager INSTANCE = new CraftingQueueManager(); - private static final int MAX_PROCESSING_LEVEL = 3; + private static final int MAX_PROCESSING_LEVEL = 2; private Map endProducts = new HashMap<>(); - private Map intermediateProducts = new HashMap<>(); - private Map rawMaterials = new HashMap<>(); - private Map fuel = new HashMap<>(); + private Map intermediateProducts = new HashMap<>(); + private Map rawMaterials = new HashMap<>(); + private Map fuel = new HashMap<>(); public CraftingQueueManager() { } @@ -100,24 +102,21 @@ public List getEndProducts() { .toList(); } - public List getIntermediates() { - return intermediateProducts.entrySet() + public List getIntermediates() { + return intermediateProducts.values() .stream() - .map(e -> new QueueItem(e.getKey(), false, e.getValue())) .toList(); } - public List getRawMaterials() { - return rawMaterials.entrySet() + public List getRawMaterials() { + return rawMaterials.values() .stream() - .map(e -> new QueueItem(e.getKey(), false, e.getValue())) .toList(); } - public List getFuel() { - return fuel.entrySet() + public List getFuel() { + return fuel.values() .stream() - .map(e -> new QueueItem(e.getKey(), false, e.getValue())) .toList(); } @@ -256,17 +255,20 @@ void coalesceProducts(ProcessingContext ctx) { r.intermediateProducts.forEach((ik, iv) -> { this.intermediateProducts.compute(ik, (ik1, iv1) -> { - return ObjectUtils.defaultIfNull(iv1, 0) + iv; + return ObjectUtils.defaultIfNull(iv1, new CraftingQueueItem(ik1, 0, false)) + .increment(iv.amount); }); }); r.rawMaterials.forEach((rk, rv) -> { this.rawMaterials.compute(rk, (rk1, rv1) -> { - return ObjectUtils.defaultIfNull(rv1, 0) + rv; + return ObjectUtils.defaultIfNull(rv1, new CraftingQueueItem(rk1, 0, false)) + .increment(rv.amount); }); }); r.fuel.forEach((fk, fv) -> { this.fuel.compute(fk, (fk1, fv1) -> { - return ObjectUtils.defaultIfNull(fv1, 0) + fv; + return ObjectUtils.defaultIfNull(fv1, new CraftingQueueItem(fk1, 0, false)) + .increment(fv.amount); }); }); }); @@ -294,7 +296,7 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { } // tally ingredients - Map ingredientTally = new HashMap<>(); + Map> ingredientTally = new HashMap<>(); for(Ingredient ingredient : ingredients) { CraftTracker.LOGGER.debug("ingredient: {}", DebugUtil.printIngredient(ingredient)); @@ -302,9 +304,27 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { continue; } + CraftTracker.LOGGER.debug("ingredient class: {}", ingredient.getClass()); + CraftTracker.LOGGER.debug("ingredient.values: {}", (Object) ingredient.values); + + Boolean tag; + if(ingredient.values.length > 0 && ingredient.values[0] instanceof Ingredient.TagValue) { + // ingredient is a tag + tag = true; + } + else { + tag = false; + } + ItemStack chosenStack = RecipeUtil.chooseLeastExpensiveOf(ingredient.getItems()); - ingredientTally.compute(chosenStack.getItem().getRegistryName(), (ingredientId, amount) -> { - return ObjectUtils.defaultIfNull(amount, 0) + 1; + ingredientTally.compute(chosenStack.getItem().getRegistryName(), (ingredientId, tuple) -> { +// return ObjectUtils.defaultIfNull(amount, 0) + 1; + tuple = ObjectUtils.defaultIfNull(tuple, new Tuple<>(false, 0)); + tuple.setA(tag); + tuple.setB(tuple.getB() + 1); +// newTuple.setA(tag); +// newTuple.setB(); + return tuple; }); } @@ -314,8 +334,10 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { Item item = ForgeRegistries.ITEMS.getValue(ingredientId); CraftTracker.LOGGER.debug("item: {}", DebugUtil.printItem(item)); - int amountRequired = ingredientAmount; // chosenStack.getCount(); + int amountRequired = ingredientAmount.getB(); // chosenStack.getCount(); CraftTracker.LOGGER.debug("amountRequired: {}", amountRequired); + boolean isTag = ingredientAmount.getA(); + CraftTracker.LOGGER.debug("isTag: {}", isTag); // check if player already has the item CraftTracker.LOGGER.debug("check if player already has {}", DebugUtil.printItem(item)); @@ -340,7 +362,7 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { // no recipes for this ingredient, so it's a raw material computedRecipe.rawMaterials.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, 0) + (amountRequired * iterations)); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(amountRequired * iterations)); } else { CraftTracker.LOGGER.debug("subRecipes has {} items; ingredient {} is an intermediate product", subRecipes.size(), ingredientId); @@ -355,29 +377,32 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { // if the sub-recipe comes back null, then treat the result item as a raw material computedRecipe.rawMaterials.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, 0) + (amountRequired * iterations)); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(amountRequired * iterations)); return; } computedRecipe.intermediateProducts.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, 0) + needsQty); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(needsQty)); // merge subrecipe items into this CraftTracker.LOGGER.debug("merging subrecipe contents: {} into this: {}", computedSubRecipe, computedRecipe); - computedSubRecipe.intermediateProducts.forEach((itemId, amount) -> { + computedSubRecipe.intermediateProducts.forEach((itemId, cri) -> { computedRecipe.intermediateProducts.compute(itemId, (k1, v1) -> { - return ObjectUtils.defaultIfNull(v1, 0) + amount; + return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) + .increase(cri.amount); }); }); - computedSubRecipe.rawMaterials.forEach((itemId, amount) -> { + computedSubRecipe.rawMaterials.forEach((itemId, cri) -> { computedRecipe.rawMaterials.compute(itemId, (k1, v1) -> { - return ObjectUtils.defaultIfNull(v1, 0) + amount; + return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) + .increase(cri.amount); }); }); - computedSubRecipe.fuel.forEach((itemId, amount) -> { + computedSubRecipe.fuel.forEach((itemId, cri) -> { computedRecipe.fuel.compute(itemId, (k1, v1) -> { - return ObjectUtils.defaultIfNull(v1, 0) + amount; + return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) + .increase(cri.amount); }); }); @@ -453,11 +478,38 @@ public String toString() { } } + class ComputedRecipeItem { + ResourceLocation itemId; + int amount; + boolean tag; + + public ComputedRecipeItem(ResourceLocation itemId) { + this.itemId = itemId; + } + + public ComputedRecipeItem increase(int amount) { + this.amount += amount; + return this; + } + + @Override + public String toString() { + return MessageFormat.format(""" + ComputedRecipeItem[ + itemId={0} + amount={1} + tag={2} + ] + """, + itemId, amount, tag); + } + } + class ComputedRecipe { ResourceLocation recipeId; - Map intermediateProducts = new HashMap<>(); - Map rawMaterials = new HashMap<>(); - Map fuel = new HashMap<>(); + Map intermediateProducts = new HashMap<>(); + Map rawMaterials = new HashMap<>(); + Map fuel = new HashMap<>(); ComputedRecipe(ResourceLocation recipeId) { this.recipeId = recipeId; diff --git a/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java b/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java new file mode 100644 index 0000000..0fbb383 --- /dev/null +++ b/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java @@ -0,0 +1,45 @@ +package com.sweetrpg.crafttracker.common.model; + +import net.minecraft.resources.ResourceLocation; + +public class CraftingQueueItem { + + ResourceLocation itemId; + int amount; + boolean tag; + + public CraftingQueueItem(ResourceLocation itemId, int amount, boolean tag) { + this.itemId = itemId; + this.amount = amount; + this.tag = tag; + } + + public CraftingQueueItem increment(int increase) { + this.amount += increase; + return this; + } + + public ResourceLocation getItemId() { + return itemId; + } + + public void setItemId(ResourceLocation itemId) { + this.itemId = itemId; + } + + public int getAmount() { + return amount; + } + + public void setAmount(int amount) { + this.amount = amount; + } + + public boolean isTag() { + return tag; + } + + public void setTag(boolean tag) { + this.tag = tag; + } +} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg index 3760722..b772753 100644 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ b/src/main/resources/META-INF/accesstransformer.cfg @@ -3,3 +3,6 @@ public net.minecraft.client.gui.screens.Screen f_96545_ # buttons # RecipeManager public net.minecraft.world.item.crafting.RecipeManager m_44054_(Lnet/minecraft/world/item/crafting/RecipeType;)Ljava/util/Map; # byType + +# Ingredient +public net.minecraft.world.item.crafting.Ingredient f_43902_ # values From fe6e4659d26a794dcdf158147e912e6667ad87dc Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Wed, 4 Dec 2024 08:27:20 -0800 Subject: [PATCH 19/24] Revert int to float change (broke cost calculation) --- .../crafttracker/common/util/RecipeUtil.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index e573379..9e00e90 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -99,12 +99,12 @@ public static boolean areIngredientsSameNamespace(String namespace, NonNullList< return ing.size() == 1; } - public static float calculateRecipeCost(Recipe recipe) { + public static int calculateRecipeCost(Recipe recipe) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: {}", DebugUtil.printRecipe(recipe)); - float cost = recipe.getIngredients().stream() + int cost = recipe.getIngredients().stream() .map(RecipeUtil::calculateIngredientCost) - .reduce(0f, Float::sum); + .reduce(0, Integer::sum); // if the item's namespace is not 'minecraft:', increase the cost if(!recipe.getId().getNamespace().equals("minecraft")) { @@ -122,7 +122,7 @@ public static float calculateRecipeCost(Recipe recipe) { return cost; } - public static float calculateIngredientCost(Ingredient ingredient) { + public static int calculateIngredientCost(Ingredient ingredient) { CraftTracker.LOGGER.debug("RecipeUtil#getIngredientCost: {}", DebugUtil.printIngredient(ingredient)); for(ItemStack stack : ingredient.getItems()) { @@ -136,12 +136,12 @@ public static float calculateIngredientCost(Ingredient ingredient) { } // it's not, so check its tags - float highestCost = 0; + int highestCost = 0; for(TagKey tag : stack.getTags().toList()) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); - float cost = ingredientCostsByTag.get(tagId) * count; + int cost = ingredientCostsByTag.get(tagId) * count; // if the item's namespace is not 'minecraft:', increase the cost if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && @@ -165,7 +165,7 @@ public static float calculateIngredientCost(Ingredient ingredient) { return 1; } - public static float calculateItemCost(ItemStack stack) { + public static int calculateItemCost(ItemStack stack) { CraftTracker.LOGGER.debug("#calculateItemCost: {}", DebugUtil.printItemStack(stack)); var itemId = stack.getItem().getRegistryName(); @@ -177,12 +177,12 @@ public static float calculateItemCost(ItemStack stack) { } // it's not, so check its tags - float highestCost = 0; + int highestCost = 0; for(TagKey tag : stack.getTags().toList()) { var tagId = tag.location(); if(ingredientCostsByTag.containsKey(tagId)) { CraftTracker.LOGGER.debug("found item {} in tag list", tagId); - double cost = ingredientCostsByTag.get(tagId) * count; + int cost = ingredientCostsByTag.get(tagId) * count; // if the item's namespace is not 'minecraft:', increase the cost if(!ObjectUtils.defaultIfNull(stack.getItem().getRegistryName().getNamespace(), "").equals("minecraft") && @@ -213,7 +213,7 @@ public static Recipe chooseLeastExpensiveOf(List> recipes return recipes.get(0); } - List, Float>> recipeCosts = new ArrayList<>(); + List, Integer>> recipeCosts = new ArrayList<>(); for(Recipe recipe : recipes) { var cost = RecipeUtil.calculateRecipeCost(recipe); @@ -240,7 +240,7 @@ public static ItemStack chooseLeastExpensiveOf(ItemStack[] stacks) { return stacks[0]; } - List> itemCosts = new ArrayList<>(); + List> itemCosts = new ArrayList<>(); for(ItemStack stack : stacks) { var cost = RecipeUtil.calculateItemCost(stack); From 980a3e78a90b7c9289bd43a10fa33f542919078b Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Wed, 4 Dec 2024 16:28:35 +0000 Subject: [PATCH 20/24] Update 1.18 VERSION file --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index 9767cc9..20f4951 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.1.10 +0.1.11 From 3f446c49ba98a2d96aea63b377cae78b3e327f4b Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Wed, 4 Dec 2024 19:16:14 -0800 Subject: [PATCH 21/24] Propagate the tag information --- .../client/overlay/CraftQueueOverlay.java | 2 +- .../common/manager/CraftingQueueManager.java | 35 ++++++++++++++----- .../common/model/CraftingQueueItem.java | 9 +++-- 3 files changed, 33 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java index 2bfce1f..32a65e0 100644 --- a/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java +++ b/src/main/java/com/sweetrpg/crafttracker/client/overlay/CraftQueueOverlay.java @@ -123,7 +123,7 @@ public class CraftQueueOverlay { } Player player = Minecraft.getInstance().player; - var inventory = player.getInventory(); +// var inventory = player.getInventory(); // SECTION: intermediates diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index b58bcd8..6e9be48 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -256,19 +256,22 @@ void coalesceProducts(ProcessingContext ctx) { r.intermediateProducts.forEach((ik, iv) -> { this.intermediateProducts.compute(ik, (ik1, iv1) -> { return ObjectUtils.defaultIfNull(iv1, new CraftingQueueItem(ik1, 0, false)) - .increment(iv.amount); + .increment(iv.amount) + .setTag(iv.tag); }); }); r.rawMaterials.forEach((rk, rv) -> { this.rawMaterials.compute(rk, (rk1, rv1) -> { return ObjectUtils.defaultIfNull(rv1, new CraftingQueueItem(rk1, 0, false)) - .increment(rv.amount); + .increment(rv.amount) + .setTag(rv.tag); }); }); r.fuel.forEach((fk, fv) -> { this.fuel.compute(fk, (fk1, fv1) -> { return ObjectUtils.defaultIfNull(fv1, new CraftingQueueItem(fk1, 0, false)) - .increment(fv.amount); + .increment(fv.amount) + .setTag(fv.tag); }); }); }); @@ -362,7 +365,9 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { // no recipes for this ingredient, so it's a raw material computedRecipe.rawMaterials.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(amountRequired * iterations)); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)) + .increase(amountRequired * iterations) + .tag(isTag)); } else { CraftTracker.LOGGER.debug("subRecipes has {} items; ingredient {} is an intermediate product", subRecipes.size(), ingredientId); @@ -377,32 +382,39 @@ ComputedRecipe computeRecipe(Recipe recipe, int iterations, int depth) { // if the sub-recipe comes back null, then treat the result item as a raw material computedRecipe.rawMaterials.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(amountRequired * iterations)); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)) + .increase(amountRequired * iterations) + .tag(isTag)); return; } computedRecipe.intermediateProducts.compute(id, (itemId, quantity) -> - ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)).increase(needsQty)); + ObjectUtils.defaultIfNull(quantity, new ComputedRecipeItem(itemId)) + .increase(needsQty) + .tag(isTag)); // merge subrecipe items into this CraftTracker.LOGGER.debug("merging subrecipe contents: {} into this: {}", computedSubRecipe, computedRecipe); computedSubRecipe.intermediateProducts.forEach((itemId, cri) -> { computedRecipe.intermediateProducts.compute(itemId, (k1, v1) -> { return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) - .increase(cri.amount); + .increase(cri.amount) + .tag(cri.tag); }); }); computedSubRecipe.rawMaterials.forEach((itemId, cri) -> { computedRecipe.rawMaterials.compute(itemId, (k1, v1) -> { return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) - .increase(cri.amount); + .increase(cri.amount) + .tag(cri.tag); }); }); computedSubRecipe.fuel.forEach((itemId, cri) -> { computedRecipe.fuel.compute(itemId, (k1, v1) -> { return ObjectUtils.defaultIfNull(v1, new ComputedRecipeItem(k1)) - .increase(cri.amount); + .increase(cri.amount) + .tag(cri.tag); }); }); @@ -492,6 +504,11 @@ public ComputedRecipeItem increase(int amount) { return this; } + public ComputedRecipeItem tag(boolean tag) { + this.tag = tag; + return this; + } + @Override public String toString() { return MessageFormat.format(""" diff --git a/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java b/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java index 0fbb383..37a8584 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/model/CraftingQueueItem.java @@ -23,23 +23,26 @@ public ResourceLocation getItemId() { return itemId; } - public void setItemId(ResourceLocation itemId) { + public CraftingQueueItem setItemId(ResourceLocation itemId) { this.itemId = itemId; + return this; } public int getAmount() { return amount; } - public void setAmount(int amount) { + public CraftingQueueItem setAmount(int amount) { this.amount = amount; + return this; } public boolean isTag() { return tag; } - public void setTag(boolean tag) { + public CraftingQueueItem setTag(boolean tag) { this.tag = tag; + return this; } } From b0400fddeac1c9b9329201c0805f25bc0bf3173a Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Wed, 4 Dec 2024 19:19:26 -0800 Subject: [PATCH 22/24] Restore previous processing level --- CHANGELOG/1.18/current.md | 1 + .../crafttracker/common/manager/CraftingQueueManager.java | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG/1.18/current.md b/CHANGELOG/1.18/current.md index b7821d5..7e450fa 100644 --- a/CHANGELOG/1.18/current.md +++ b/CHANGELOG/1.18/current.md @@ -3,3 +3,4 @@ - `[FIX]` Increased recipe calculation depth to 3 - `[FIX]` Added checks for recipe and ingredient namespaces in determining intermediate/raw status - `[FIX]` Changed text for crafting queue sections +- `[NEW]` Intermediate and raw materials that are tags are marked with an asterisk diff --git a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java index 6e9be48..1315c33 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/manager/CraftingQueueManager.java @@ -35,7 +35,7 @@ public class CraftingQueueManager { public static CraftingQueueManager INSTANCE = new CraftingQueueManager(); - private static final int MAX_PROCESSING_LEVEL = 2; + private static final int MAX_PROCESSING_LEVEL = 3; private Map endProducts = new HashMap<>(); private Map intermediateProducts = new HashMap<>(); From 67444386e382ce9390d6965f7bf0363f7085df5e Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Wed, 4 Dec 2024 19:21:43 -0800 Subject: [PATCH 23/24] Address implicit narrowing conversion --- .../com/sweetrpg/crafttracker/common/util/RecipeUtil.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java index 9e00e90..94f779a 100644 --- a/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java +++ b/src/main/java/com/sweetrpg/crafttracker/common/util/RecipeUtil.java @@ -110,13 +110,13 @@ public static int calculateRecipeCost(Recipe recipe) { if(!recipe.getId().getNamespace().equals("minecraft")) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla recipe {} by {}", cost, DebugUtil.printRecipe(recipe), NON_VANILLA_COST_MULTIPLIER); - cost *= NON_VANILLA_COST_MULTIPLIER; + cost = (int) (cost * NON_VANILLA_COST_MULTIPLIER); } if(!(recipe instanceof CraftingRecipe)) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-crafting table recipe {} by {}", cost, DebugUtil.printRecipe(recipe), NON_CRAFTING_COST_MULTIPLIER); - cost *= NON_CRAFTING_COST_MULTIPLIER; + cost = (int) (cost * NON_VANILLA_COST_MULTIPLIER); } return cost; @@ -148,7 +148,7 @@ public static int calculateIngredientCost(Ingredient ingredient) { !ObjectUtils.defaultIfNull(tagId.getNamespace(), "").equals("minecraft")) { CraftTracker.LOGGER.debug("RecipeUtil#calculateRecipeCost: increasing cost ({}) of non-vanilla item {} by {}", cost, tagId, NON_VANILLA_COST_MULTIPLIER); - cost *= NON_VANILLA_COST_MULTIPLIER; + cost = (int) (cost * NON_VANILLA_COST_MULTIPLIER); } if(cost > highestCost) { @@ -189,7 +189,7 @@ public static int calculateItemCost(ItemStack stack) { !ObjectUtils.defaultIfNull(tagId.getNamespace(), "").equals("minecraft")) { CraftTracker.LOGGER.debug("RecipeUtil#calculateItemCost: increasing cost ({}) of non-vanilla item {} by {}", cost, tagId, NON_VANILLA_COST_MULTIPLIER); - cost *= NON_VANILLA_COST_MULTIPLIER; + cost = (int) (cost * NON_VANILLA_COST_MULTIPLIER); } if(cost > highestCost) { From a926f8d4ad5ea15588e5c385162f4c322f8f39bb Mon Sep 17 00:00:00 2001 From: SweetRPG CI Date: Thu, 5 Dec 2024 03:32:41 +0000 Subject: [PATCH 24/24] Update 1.18 VERSION file --- .release-info/1.18/VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.release-info/1.18/VERSION b/.release-info/1.18/VERSION index 20f4951..0e24a92 100644 --- a/.release-info/1.18/VERSION +++ b/.release-info/1.18/VERSION @@ -1 +1 @@ -0.1.11 +0.1.12