54 lines
2.0 KiB
Java
54 lines
2.0 KiB
Java
/*
|
|
* Decompiled with CFR 0.152.
|
|
*/
|
|
package net.minecraft.world.item.crafting;
|
|
|
|
import net.minecraft.core.NonNullList;
|
|
import net.minecraft.world.item.Item;
|
|
import net.minecraft.world.item.ItemStack;
|
|
import net.minecraft.world.item.crafting.CraftingBookCategory;
|
|
import net.minecraft.world.item.crafting.CraftingInput;
|
|
import net.minecraft.world.item.crafting.Recipe;
|
|
import net.minecraft.world.item.crafting.RecipeBookCategories;
|
|
import net.minecraft.world.item.crafting.RecipeBookCategory;
|
|
import net.minecraft.world.item.crafting.RecipeSerializer;
|
|
import net.minecraft.world.item.crafting.RecipeType;
|
|
|
|
public interface CraftingRecipe
|
|
extends Recipe<CraftingInput> {
|
|
@Override
|
|
default public RecipeType<CraftingRecipe> getType() {
|
|
return RecipeType.CRAFTING;
|
|
}
|
|
|
|
@Override
|
|
public RecipeSerializer<? extends CraftingRecipe> getSerializer();
|
|
|
|
public CraftingBookCategory category();
|
|
|
|
default public NonNullList<ItemStack> getRemainingItems(CraftingInput input) {
|
|
return CraftingRecipe.defaultCraftingReminder(input);
|
|
}
|
|
|
|
public static NonNullList<ItemStack> defaultCraftingReminder(CraftingInput input) {
|
|
NonNullList<ItemStack> result = NonNullList.withSize(input.size(), ItemStack.EMPTY);
|
|
for (int slot = 0; slot < result.size(); ++slot) {
|
|
Item item = input.getItem(slot).getItem();
|
|
result.set(slot, item.getCraftingRemainder());
|
|
}
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
default public RecipeBookCategory recipeBookCategory() {
|
|
return switch (this.category()) {
|
|
default -> throw new MatchException(null, null);
|
|
case CraftingBookCategory.BUILDING -> RecipeBookCategories.CRAFTING_BUILDING_BLOCKS;
|
|
case CraftingBookCategory.EQUIPMENT -> RecipeBookCategories.CRAFTING_EQUIPMENT;
|
|
case CraftingBookCategory.REDSTONE -> RecipeBookCategories.CRAFTING_REDSTONE;
|
|
case CraftingBookCategory.MISC -> RecipeBookCategories.CRAFTING_MISC;
|
|
};
|
|
}
|
|
}
|
|
|