/
DebugRecipeCategory.java
146 lines (127 loc) · 5.44 KB
/
DebugRecipeCategory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
package mezz.jei.plugins.jei.debug;
import java.util.Collections;
import java.util.List;
import mezz.jei.api.IGuiHelper;
import mezz.jei.api.IItemListOverlay;
import mezz.jei.api.IJeiRuntime;
import mezz.jei.api.gui.IDrawable;
import mezz.jei.api.gui.IGuiFluidStackGroup;
import mezz.jei.api.gui.IGuiIngredientGroup;
import mezz.jei.api.gui.IGuiItemStackGroup;
import mezz.jei.api.gui.IRecipeLayout;
import mezz.jei.api.gui.ITooltipCallback;
import mezz.jei.api.ingredients.IIngredientHelper;
import mezz.jei.api.ingredients.IIngredientRegistry;
import mezz.jei.api.ingredients.IIngredients;
import mezz.jei.api.recipe.BlankRecipeCategory;
import mezz.jei.config.Constants;
import mezz.jei.plugins.jei.JEIInternalPlugin;
import mezz.jei.plugins.jei.ingredients.DebugIngredient;
import mezz.jei.plugins.jei.ingredients.DebugIngredientRenderer;
import net.minecraft.client.Minecraft;
import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fluids.FluidStack;
public class DebugRecipeCategory extends BlankRecipeCategory<DebugRecipe> {
public static final int recipeWidth = 160;
public static final int recipeHeight = 60;
private final IDrawable background;
private final String localizedName;
private final IDrawable tankBackground;
private final IDrawable tankOverlay;
public DebugRecipeCategory(IGuiHelper guiHelper) {
background = guiHelper.createBlankDrawable(recipeWidth, recipeHeight);
localizedName = "debug";
ResourceLocation backgroundTexture = new ResourceLocation(Constants.RESOURCE_DOMAIN, Constants.TEXTURE_RECIPE_BACKGROUND_PATH);
tankBackground = guiHelper.createDrawable(backgroundTexture, 176, 0, 20, 55);
tankOverlay = guiHelper.createDrawable(backgroundTexture, 176, 55, 12, 47);
}
@Override
public String getUid() {
return "debug";
}
@Override
public String getTitle() {
return localizedName;
}
@Override
public IDrawable getBackground() {
return background;
}
@Override
public void drawExtras(Minecraft minecraft) {
tankBackground.draw(minecraft);
IJeiRuntime runtime = JEIInternalPlugin.jeiRuntime;
if (runtime != null) {
IItemListOverlay itemListOverlay = runtime.getItemListOverlay();
minecraft.fontRendererObj.drawString(itemListOverlay.getFilterText(), 20, 52, 0);
ItemStack stackUnderMouse = itemListOverlay.getStackUnderMouse();
if (stackUnderMouse != null) {
IIngredientRegistry ingredientRegistry = JEIInternalPlugin.ingredientRegistry;
if (ingredientRegistry != null) {
IIngredientHelper<ItemStack> ingredientHelper = ingredientRegistry.getIngredientHelper(stackUnderMouse);
String jeiUid = ingredientHelper.getUniqueId(stackUnderMouse);
minecraft.fontRendererObj.drawString(jeiUid, 50, 52, 0);
}
}
}
}
@Override
public void setRecipe(IRecipeLayout recipeLayout, DebugRecipe recipeWrapper, IIngredients ingredients) {
IGuiItemStackGroup guiItemStacks = recipeLayout.getItemStacks();
guiItemStacks.addTooltipCallback(new ITooltipCallback<ItemStack>() {
@Override
public void onTooltip(int slotIndex, boolean input, ItemStack ingredient, List<String> tooltip) {
if (input) {
tooltip.add(slotIndex + " Input itemStack");
} else {
tooltip.add(slotIndex + " Output itemStack");
}
}
});
guiItemStacks.init(0, false, 70, 0);
guiItemStacks.init(1, true, 110, 0);
guiItemStacks.set(0, new ItemStack(Items.WATER_BUCKET));
guiItemStacks.set(1, new ItemStack(Items.LAVA_BUCKET));
IGuiFluidStackGroup guiFluidStacks = recipeLayout.getFluidStacks();
guiFluidStacks.addTooltipCallback(new ITooltipCallback<FluidStack>() {
@Override
public void onTooltip(int slotIndex, boolean input, FluidStack ingredient, List<String> tooltip) {
if (input) {
tooltip.add(slotIndex + " Input fluidStack");
} else {
tooltip.add(slotIndex + " Output fluidStack");
}
}
});
guiFluidStacks.init(0, true, 4, 4, 12, 47, 2000, true, tankOverlay);
guiFluidStacks.init(1, true, 24, 0, 12, 47, 16000, true, null);
guiFluidStacks.init(2, false, 50, 0, 24, 24, 2000, true, tankOverlay);
guiFluidStacks.init(3, false, 90, 0, 12, 47, 100, false, tankOverlay);
List<FluidStack> fluidInputs = recipeWrapper.getFluidInputs();
guiFluidStacks.set(0, fluidInputs.get(0));
guiFluidStacks.set(1, fluidInputs.get(1));
guiFluidStacks.set(3, fluidInputs.get(0));
IGuiIngredientGroup<DebugIngredient> debugIngredientsGroup = recipeLayout.getIngredientsGroup(DebugIngredient.class);
debugIngredientsGroup.addTooltipCallback(new ITooltipCallback<DebugIngredient>() {
@Override
public void onTooltip(int slotIndex, boolean input, DebugIngredient ingredient, List<String> tooltip) {
if (input) {
tooltip.add(slotIndex + " Input DebugIngredient");
} else {
tooltip.add(slotIndex + " Output DebugIngredient");
}
}
});
DebugIngredientRenderer ingredientRenderer = new DebugIngredientRenderer();
debugIngredientsGroup.init(0, true, ingredientRenderer, 40, 0, 16, 16, 0, 0);
debugIngredientsGroup.init(1, false, ingredientRenderer, 40, 16, 16, 16, 0, 0);
debugIngredientsGroup.init(2, false, ingredientRenderer, 40, 32, 16, 16, 0, 0);
debugIngredientsGroup.set(ingredients);
}
@Override
public List<String> getTooltipStrings(int mouseX, int mouseY) {
return Collections.singletonList("Debug Recipe Category Tooltip");
}
}