FurnaceRecipeBookComponent.java

net.minecraft.client.gui.screens.recipebook.FurnaceRecipeBookComponent

信息

  • 全限定名:net.minecraft.client.gui.screens.recipebook.FurnaceRecipeBookComponent
  • 类型:public class
  • 包:net.minecraft.client.gui.screens.recipebook
  • 源码路径:src/main/java/net/minecraft/client/gui/screens/recipebook/FurnaceRecipeBookComponent.java
  • 起始行号:L17
  • 继承:RecipeBookComponent
  • 职责:

    TODO

字段/常量

  • FILTER_SPRITES

    • 类型: WidgetSprites
    • 修饰符: private static final
    • 源码定位: L18
    • 说明:

      TODO

  • recipeFilterName

    • 类型: Component
    • 修饰符: private final
    • 源码定位: L24
    • 说明:

      TODO

内部类/嵌套类型

构造器

public FurnaceRecipeBookComponent(AbstractFurnaceMenu menu, Component recipeFilterName, List<RecipeBookComponent.TabInfo> tabInfos) @ L26

  • 构造器名:FurnaceRecipeBookComponent
  • 源码定位:L26
  • 修饰符:public

参数:

  • menu: AbstractFurnaceMenu
  • recipeFilterName: Component
  • tabInfos: List<RecipeBookComponent.TabInfo>

说明:

TODO

方法

下面的方法块按源码顺序生成。

protected WidgetSprites getFilterButtonTextures() @ L31

  • 方法名:getFilterButtonTextures
  • 源码定位:L31
  • 返回类型:WidgetSprites
  • 修饰符:protected

参数:

说明:

TODO

protected boolean isCraftingSlot(Slot slot) @ L36

  • 方法名:isCraftingSlot
  • 源码定位:L36
  • 返回类型:boolean
  • 修饰符:protected

参数:

  • slot: Slot

说明:

TODO

protected void fillGhostRecipe(GhostSlots ghostSlots, RecipeDisplay recipe, ContextMap context) @ L44

  • 方法名:fillGhostRecipe
  • 源码定位:L44
  • 返回类型:void
  • 修饰符:protected

参数:

  • ghostSlots: GhostSlots
  • recipe: RecipeDisplay
  • context: ContextMap

说明:

TODO

protected Component getRecipeFilterName() @ L56

  • 方法名:getRecipeFilterName
  • 源码定位:L56
  • 返回类型:Component
  • 修饰符:protected

参数:

说明:

TODO

protected void selectMatchingRecipes(RecipeCollection collection, StackedItemContents stackedContents) @ L61

  • 方法名:selectMatchingRecipes
  • 源码定位:L61
  • 返回类型:void
  • 修饰符:protected

参数:

  • collection: RecipeCollection
  • stackedContents: StackedItemContents

说明:

TODO

代码

@OnlyIn(Dist.CLIENT)
public class FurnaceRecipeBookComponent extends RecipeBookComponent<AbstractFurnaceMenu> {
    private static final WidgetSprites FILTER_SPRITES = new WidgetSprites(
        Identifier.withDefaultNamespace("recipe_book/furnace_filter_enabled"),
        Identifier.withDefaultNamespace("recipe_book/furnace_filter_disabled"),
        Identifier.withDefaultNamespace("recipe_book/furnace_filter_enabled_highlighted"),
        Identifier.withDefaultNamespace("recipe_book/furnace_filter_disabled_highlighted")
    );
    private final Component recipeFilterName;
 
    public FurnaceRecipeBookComponent(AbstractFurnaceMenu menu, Component recipeFilterName, List<RecipeBookComponent.TabInfo> tabInfos) {
        super(menu, tabInfos);
        this.recipeFilterName = recipeFilterName;
    }
 
    @Override
    protected WidgetSprites getFilterButtonTextures() {
        return FILTER_SPRITES;
    }
 
    @Override
    protected boolean isCraftingSlot(Slot slot) {
        return switch (slot.index) {
            case 0, 1, 2 -> true;
            default -> false;
        };
    }
 
    @Override
    protected void fillGhostRecipe(GhostSlots ghostSlots, RecipeDisplay recipe, ContextMap context) {
        ghostSlots.setResult(this.menu.getResultSlot(), context, recipe.result());
        if (recipe instanceof FurnaceRecipeDisplay furnaceRecipe) {
            ghostSlots.setInput(this.menu.slots.get(0), context, furnaceRecipe.ingredient());
            Slot fuelSlot = this.menu.slots.get(1);
            if (fuelSlot.getItem().isEmpty()) {
                ghostSlots.setInput(fuelSlot, context, furnaceRecipe.fuel());
            }
        }
    }
 
    @Override
    protected Component getRecipeFilterName() {
        return this.recipeFilterName;
    }
 
    @Override
    protected void selectMatchingRecipes(RecipeCollection collection, StackedItemContents stackedContents) {
        collection.selectRecipes(stackedContents, display -> display instanceof FurnaceRecipeDisplay);
    }
}

引用的其他类