FurnaceRecipeBookComponent .java

net.minecraft.client.gui.screens.recipebook.FurnaceRecipeBookComponent (class, 66 lines): members: FILTER_SPRITES, recipeFilterName, selectMatchingRecipes.

net.minecraft.client.gui.screens.recipebookclass66 linesclientextends RecipeBookComponent<AbstractFurnaceMenu>2.4 KB

API Surface (5)

WidgetSprites getFilterButtonTextures()
boolean isCraftingSlot(final Slot slot)
void fillGhostRecipe(final GhostSlots ghostSlots, final RecipeDisplay recipe, final ContextMap context)
Component getRecipeFilterName()
void selectMatchingRecipes(final RecipeCollection collection, final StackedItemContents stackedContents)

Fields & Constants (2)

FILTER_SPRITES
recipeFilterName

String literals (4)

"recipe_book/furnace_filter_enabled"
"recipe_book/furnace_filter_disabled"
"recipe_book/furnace_filter_enabled_highlighted"
"recipe_book/furnace_filter_disabled_highlighted"

Full Source

FurnaceRecipeBookComponent.java66 lines · Minecraft 26.3 · verbatim
1
package net.minecraft.client.gui.screens.recipebook;
2
3
import java.util.List;
4
import net.fabricmc.api.EnvType;
5
import net.fabricmc.api.Environment;
6
import net.minecraft.client.gui.components.WidgetSprites;
7
import net.minecraft.network.chat.Component;
8
import net.minecraft.resources.Identifier;
9
import net.minecraft.util.context.ContextMap;
10
import net.minecraft.world.entity.player.StackedItemContents;
11
import net.minecraft.world.inventory.AbstractFurnaceMenu;
12
import net.minecraft.world.inventory.Slot;
13
import net.minecraft.world.item.crafting.display.FurnaceRecipeDisplay;
14
import net.minecraft.world.item.crafting.display.RecipeDisplay;
15
16
@Environment(EnvType.CLIENT)
17
public class FurnaceRecipeBookComponent extends RecipeBookComponent<AbstractFurnaceMenu> {
18
	private static final WidgetSprites FILTER_SPRITES = new WidgetSprites(
19
		Identifier.withDefaultNamespace("recipe_book/furnace_filter_enabled"),
20
		Identifier.withDefaultNamespace("recipe_book/furnace_filter_disabled"),
21
		Identifier.withDefaultNamespace("recipe_book/furnace_filter_enabled_highlighted"),
22
		Identifier.withDefaultNamespace("recipe_book/furnace_filter_disabled_highlighted")
23
	);
24
	private final Component recipeFilterName;
25
26
	public FurnaceRecipeBookComponent(final AbstractFurnaceMenu menu, final Component recipeFilterName, final List<RecipeBookComponent.TabInfo> tabInfos) {
27
		super(menu, tabInfos);
28
		this.recipeFilterName = recipeFilterName;
29
	}
30
31
	@Override
32
	protected WidgetSprites getFilterButtonTextures() {
33
		return FILTER_SPRITES;
34
	}
35
36
	@Override
37
	protected boolean isCraftingSlot(final Slot slot) {
38
		return switch (slot.index) {
39
			case 0, 1, 2 -> true;
40
			default -> false;
41
		};
42
	}
43
44
	@Override
45
	protected void fillGhostRecipe(final GhostSlots ghostSlots, final RecipeDisplay recipe, final ContextMap context) {
46
		ghostSlots.setResult(this.menu.getResultSlot(), context, recipe.result());
47
		if (recipe instanceof FurnaceRecipeDisplay furnaceRecipe) {
48
			ghostSlots.setInput(this.menu.slots.get(0), context, furnaceRecipe.ingredient());
49
			Slot fuelSlot = this.menu.slots.get(1);
50
			if (fuelSlot.getItem().isEmpty()) {
51
				ghostSlots.setInput(fuelSlot, context, furnaceRecipe.fuel());
52
			}
53
		}
54
	}
55
56
	@Override
57
	protected Component getRecipeFilterName() {
58
		return this.recipeFilterName;
59
	}
60
61
	@Override
62
	protected void selectMatchingRecipes(final RecipeCollection collection, final StackedItemContents stackedContents) {
63
		collection.selectRecipes(stackedContents, display -> display instanceof FurnaceRecipeDisplay);
64
	}
65
}
66

Decompiled Minecraft 26.3 source of FurnaceRecipeBookComponent (net/minecraft/client/gui/screens/recipebook/FurnaceRecipeBookComponent.java) with Mojang official mappings, stored verbatim on the site.