Skip to content

Commit

Permalink
Prevent removed mods' food from becoming air on read and crashes (#10579
Browse files Browse the repository at this point in the history
)

Verify each item is actually food before adding it back to the menu
  • Loading branch information
Thodor12 authored Jan 12, 2025
1 parent abbb0d9 commit 09c81a1
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +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.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;
Expand Down Expand Up @@ -205,7 +202,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 (FoodUtils.EDIBLE.test(itemStack))
{
menu.add(new ItemStorage(itemStack));
}
}
}

Expand Down

0 comments on commit 09c81a1

Please sign in to comment.