From 6cd0e6c7ee393b086d055eb8792f0e04ff35d32e Mon Sep 17 00:00:00 2001 From: Paul Schifferer Date: Tue, 3 Dec 2024 17:12:44 -0800 Subject: [PATCH] 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; }