From c46a9c3407b5a0aea927b8af15c5e4b3984f3c90 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Tue, 7 Jan 2025 17:58:02 +0100 Subject: [PATCH 1/2] Prevent removed mods' food from becoming air on read and causing failures further on --- .../colony/buildings/modules/RestaurantMenuModule.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java index 33cf6643f14..68106a4bd8f 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java @@ -12,6 +12,7 @@ import com.minecolonies.api.colony.requestsystem.token.IToken; import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.crafting.RecipeStorage; +import com.minecolonies.api.items.IMinecoloniesFoodItem; import com.minecolonies.api.util.InventoryUtils; import com.minecolonies.api.util.ItemStackUtils; import com.minecolonies.api.util.MathUtils; @@ -29,6 +30,7 @@ import java.util.function.Predicate; import static com.minecolonies.api.research.util.ResearchConstants.MIN_ORDER; +import static com.minecolonies.api.util.ItemStackUtils.ISFOOD; /** * Minimum stock module. @@ -205,7 +207,11 @@ public void deserializeNBT(final CompoundTag compound) final ListTag minimumStockTagList = compound.getList(TAG_MENU, Tag.TAG_COMPOUND); for (int i = 0; i < minimumStockTagList.size(); i++) { - menu.add(new ItemStorage(ItemStack.of(minimumStockTagList.getCompound(i)))); + final ItemStack itemStack = ItemStack.of(minimumStockTagList.getCompound(i)); + if (ISFOOD.test(itemStack) || itemStack.getItem() instanceof IMinecoloniesFoodItem) + { + menu.add(new ItemStorage(itemStack)); + } } } From 4ad55ee90f4c31b5c113678fa8fd0cdc351c8c12 Mon Sep 17 00:00:00 2001 From: Thom van den Akker Date: Sun, 12 Jan 2025 19:01:38 +0100 Subject: [PATCH 2/2] Change condition --- .../colony/buildings/modules/RestaurantMenuModule.java | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java index 68106a4bd8f..27695c4e9b4 100644 --- a/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java +++ b/src/main/java/com/minecolonies/core/colony/buildings/modules/RestaurantMenuModule.java @@ -12,11 +12,7 @@ import com.minecolonies.api.colony.requestsystem.token.IToken; import com.minecolonies.api.crafting.ItemStorage; import com.minecolonies.api.crafting.RecipeStorage; -import com.minecolonies.api.items.IMinecoloniesFoodItem; -import com.minecolonies.api.util.InventoryUtils; -import com.minecolonies.api.util.ItemStackUtils; -import com.minecolonies.api.util.MathUtils; -import com.minecolonies.api.util.WorldUtil; +import com.minecolonies.api.util.*; import net.minecraft.nbt.CompoundTag; import net.minecraft.nbt.ListTag; import net.minecraft.nbt.Tag; @@ -30,7 +26,6 @@ import java.util.function.Predicate; import static com.minecolonies.api.research.util.ResearchConstants.MIN_ORDER; -import static com.minecolonies.api.util.ItemStackUtils.ISFOOD; /** * Minimum stock module. @@ -208,7 +203,7 @@ public void deserializeNBT(final CompoundTag compound) for (int i = 0; i < minimumStockTagList.size(); i++) { final ItemStack itemStack = ItemStack.of(minimumStockTagList.getCompound(i)); - if (ISFOOD.test(itemStack) || itemStack.getItem() instanceof IMinecoloniesFoodItem) + if (FoodUtils.EDIBLE.test(itemStack)) { menu.add(new ItemStorage(itemStack)); }