/* * Decompiled with CFR 0.152. */ package net.minecraft.world.item.crafting; import net.minecraft.core.HolderLookup; import net.minecraft.core.component.DataComponents; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.Items; import net.minecraft.world.item.crafting.CraftingBookCategory; import net.minecraft.world.item.crafting.CraftingInput; import net.minecraft.world.item.crafting.CustomRecipe; import net.minecraft.world.item.crafting.RecipeSerializer; import net.minecraft.world.level.Level; public class TippedArrowRecipe extends CustomRecipe { public TippedArrowRecipe(CraftingBookCategory category) { super(category); } @Override public boolean matches(CraftingInput input, Level level) { if (input.width() != 3 || input.height() != 3 || input.ingredientCount() != 9) { return false; } for (int y = 0; y < input.height(); ++y) { for (int x = 0; x < input.width(); ++x) { ItemStack ingredient = input.getItem(x, y); if (ingredient.isEmpty()) { return false; } if (!(x == 1 && y == 1 ? !ingredient.is(Items.LINGERING_POTION) : !ingredient.is(Items.ARROW))) continue; return false; } } return true; } @Override public ItemStack assemble(CraftingInput input, HolderLookup.Provider registries) { ItemStack potion = input.getItem(1, 1); if (!potion.is(Items.LINGERING_POTION)) { return ItemStack.EMPTY; } ItemStack result = new ItemStack(Items.TIPPED_ARROW, 8); result.set(DataComponents.POTION_CONTENTS, potion.get(DataComponents.POTION_CONTENTS)); return result; } @Override public RecipeSerializer getSerializer() { return RecipeSerializer.TIPPED_ARROW; } }