Skip to content

Commit

Permalink
Merge pull request #294 from Matyrobbrt/fix-293
Browse files Browse the repository at this point in the history
Fix woodless drawer recipe and other misc fixes
  • Loading branch information
Buuz135 authored Jul 19, 2024
2 parents 12249b6 + 23c4f0f commit ad0c7de
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

Expand All @@ -26,15 +24,15 @@ public class DrawerlessWoodIngredient implements ICustomIngredient {
public static Holder<IngredientType<?>> TYPE;
public static final ResourceLocation NAME = com.buuz135.functionalstorage.util.Utils.resourceLocation(MOD_ID, "woodless");

private List<Item> woodless;
private Set<Item> woodless;

@Override
public Stream<ItemStack> getItems() {
return getWoods().stream().map(ItemStack::new);
}

@Override
public boolean test(@Nullable ItemStack stack) {
public boolean test(ItemStack stack) {
return getWoods().contains(stack.getItem());
}

Expand All @@ -48,12 +46,10 @@ public IngredientType<?> getType() {
return TYPE.value();
}

private List<Item> getWoods(){
private Set<Item> 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;
}
Expand Down

0 comments on commit ad0c7de

Please sign in to comment.