diff --git a/src/main/java/com/buuz135/functionalstorage/inventory/ArmoryCabinetInventoryHandler.java b/src/main/java/com/buuz135/functionalstorage/inventory/ArmoryCabinetInventoryHandler.java index c44c510a..df9092e7 100644 --- a/src/main/java/com/buuz135/functionalstorage/inventory/ArmoryCabinetInventoryHandler.java +++ b/src/main/java/com/buuz135/functionalstorage/inventory/ArmoryCabinetInventoryHandler.java @@ -41,11 +41,12 @@ public ItemStack getStackInSlot(int slot) { @Override public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate) { if (isValid(slot, stack)) { - if (!simulate){ - this.stackList.set(slot, stack); + if (!simulate) { + this.stackList.set(slot, stack.copyWithCount(1)); onChange(); } - return ItemStack.EMPTY; + + return stack.getCount() > 1 ? stack.copyWithCount(stack.getCount() - 1) : ItemStack.EMPTY; } return stack; } @@ -55,12 +56,13 @@ public ItemStack insertItem(int slot, @NotNull ItemStack stack, boolean simulate @NotNull @Override public ItemStack extractItem(int slot, int amount, boolean simulate) { - if (!simulate){ - ItemStack stack = this.stackList.set(slot, ItemStack.EMPTY); + var inSlot = this.stackList.get(slot).copy(); + if (amount == 0 || inSlot.isEmpty()) return inSlot; + if (!simulate) { + stackList.set(slot, ItemStack.EMPTY); onChange(); - return stack; } - return this.stackList.get(slot); + return inSlot; } @Override diff --git a/src/main/java/com/buuz135/functionalstorage/recipe/DrawerlessWoodIngredient.java b/src/main/java/com/buuz135/functionalstorage/recipe/DrawerlessWoodIngredient.java index c9b6c962..09dbaf09 100644 --- a/src/main/java/com/buuz135/functionalstorage/recipe/DrawerlessWoodIngredient.java +++ b/src/main/java/com/buuz135/functionalstorage/recipe/DrawerlessWoodIngredient.java @@ -1,7 +1,6 @@ package com.buuz135.functionalstorage.recipe; import com.hrznstudio.titanium.util.TagUtil; -import com.mojang.serialization.Codec; import com.mojang.serialization.MapCodec; import net.minecraft.core.Holder; import net.minecraft.core.registries.BuiltInRegistries; @@ -10,12 +9,11 @@ import net.minecraft.world.item.Item; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; -import net.minecraft.world.item.crafting.Ingredient; import net.neoforged.neoforge.common.crafting.ICustomIngredient; import net.neoforged.neoforge.common.crafting.IngredientType; -import org.jetbrains.annotations.Nullable; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -26,7 +24,7 @@ public class DrawerlessWoodIngredient implements ICustomIngredient { public static Holder> TYPE; public static final ResourceLocation NAME = com.buuz135.functionalstorage.util.Utils.resourceLocation(MOD_ID, "woodless"); - private List woodless; + private Set woodless; @Override public Stream getItems() { @@ -34,7 +32,7 @@ public Stream getItems() { } @Override - public boolean test(@Nullable ItemStack stack) { + public boolean test(ItemStack stack) { return getWoods().contains(stack.getItem()); } @@ -48,12 +46,10 @@ public IngredientType getType() { return TYPE.value(); } - private List getWoods(){ + private Set getWoods(){ if (woodless == null){ - woodless = TagUtil.getAllEntries(BuiltInRegistries.ITEM, ItemTags.PLANKS).stream().filter(item -> !BuiltInRegistries.ITEM.getKey(item).getNamespace().equalsIgnoreCase("minecraft")).collect(Collectors.toList()); - if (woodless.isEmpty()){ - woodless.add(Items.OAK_PLANKS); - } + woodless = TagUtil.getAllEntries(BuiltInRegistries.ITEM, ItemTags.PLANKS).stream().filter(item -> !BuiltInRegistries.ITEM.getKey(item).getNamespace().equalsIgnoreCase(ResourceLocation.DEFAULT_NAMESPACE)).collect(Collectors.toSet()); + woodless.add(Items.OAK_PLANKS); } return woodless; }