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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
package me.shedaniel.rei.plugin;
import com.google.common.collect.Lists;
import me.shedaniel.rei.api.IRecipePlugin;
import me.shedaniel.rei.api.SpeedCraftFunctional;
import me.shedaniel.rei.client.RecipeHelper;
import me.shedaniel.rei.listeners.IMixinRecipeBookGui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Gui;
import net.minecraft.client.gui.container.BlastFurnaceGui;
import net.minecraft.client.gui.container.CraftingTableGui;
import net.minecraft.client.gui.container.FurnaceGui;
import net.minecraft.client.gui.container.SmokerGui;
import net.minecraft.client.gui.ingame.PlayerInventoryGui;
import net.minecraft.recipe.Recipe;
import net.minecraft.recipe.StonecuttingRecipe;
import net.minecraft.recipe.cooking.BlastingRecipe;
import net.minecraft.recipe.cooking.CampfireCookingRecipe;
import net.minecraft.recipe.cooking.SmeltingRecipe;
import net.minecraft.recipe.cooking.SmokingRecipe;
import net.minecraft.recipe.crafting.ShapedRecipe;
import net.minecraft.recipe.crafting.ShapelessRecipe;
import net.minecraft.util.Identifier;
import java.util.List;
public class DefaultPlugin implements IRecipePlugin {
public static final Identifier CRAFTING = new Identifier("roughlyenoughitems", "plugins/crafting");
public static final Identifier SMELTING = new Identifier("roughlyenoughitems", "plugins/smelting");
public static final Identifier SMOKING = new Identifier("roughlyenoughitems", "plugins/smoking");
public static final Identifier BLASTING = new Identifier("roughlyenoughitems", "plugins/blasting");
public static final Identifier CAMPFIRE = new Identifier("roughlyenoughitems", "plugins/campfire");
public static final Identifier STONE_CUTTING = new Identifier("roughlyenoughitems", "plugins/stone_cutting");
public static final Identifier BREWING = new Identifier("roughlyenoughitems", "plugins/brewing");
private static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList();
public static void registerBrewingDisplay(DefaultBrewingDisplay display) {
BREWING_DISPLAYS.add(display);
}
@Override
public void registerPluginCategories() {
RecipeHelper.registerCategory(new DefaultCraftingCategory());
RecipeHelper.registerCategory(new DefaultSmeltingCategory());
RecipeHelper.registerCategory(new DefaultSmokingCategory());
RecipeHelper.registerCategory(new DefaultBlastingCategory());
RecipeHelper.registerCategory(new DefaultCampfireCategory());
RecipeHelper.registerCategory(new DefaultStoneCuttingCategory());
RecipeHelper.registerCategory(new DefaultBrewingCategory());
}
@Override
public void registerRecipes() {
for(Recipe recipe : RecipeHelper.getRecipeManager().values())
if (recipe instanceof ShapelessRecipe)
RecipeHelper.registerRecipe(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) recipe));
else if (recipe instanceof ShapedRecipe)
RecipeHelper.registerRecipe(CRAFTING, new DefaultShapedDisplay((ShapedRecipe) recipe));
else if (recipe instanceof SmeltingRecipe)
RecipeHelper.registerRecipe(SMELTING, new DefaultSmeltingDisplay((SmeltingRecipe) recipe));
else if (recipe instanceof SmokingRecipe)
RecipeHelper.registerRecipe(SMOKING, new DefaultSmokingDisplay((SmokingRecipe) recipe));
else if (recipe instanceof BlastingRecipe)
RecipeHelper.registerRecipe(BLASTING, new DefaultBlastingDisplay((BlastingRecipe) recipe));
else if (recipe instanceof CampfireCookingRecipe)
RecipeHelper.registerRecipe(CAMPFIRE, new DefaultCampfireDisplay((CampfireCookingRecipe) recipe));
else if (recipe instanceof StonecuttingRecipe)
RecipeHelper.registerRecipe(STONE_CUTTING, new DefaultStoneCuttingDisplay((StonecuttingRecipe) recipe));
BREWING_DISPLAYS.forEach(display -> RecipeHelper.registerRecipe(BREWING, display));
}
@Override
public void registerSpeedCraft() {
RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.CAMPFIRE, null);
RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.STONE_CUTTING, null);
RecipeHelper.registerSpeedCraftButtonArea(DefaultPlugin.BREWING, null);
RecipeHelper.registerSpeedCraftFunctional(DefaultPlugin.CRAFTING, new SpeedCraftFunctional<DefaultCraftingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{PlayerInventoryGui.class, CraftingTableGui.class};
}
@Override
public boolean performAutoCraft(Gui gui, DefaultCraftingDisplay recipe) {
if (gui.getClass().isAssignableFrom(CraftingTableGui.class))
((IMixinRecipeBookGui) (((CraftingTableGui) gui).getRecipeBookGui())).getGhostSlots().reset();
else if (gui.getClass().isAssignableFrom(PlayerInventoryGui.class))
((IMixinRecipeBookGui) (((PlayerInventoryGui) gui).getRecipeBookGui())).getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Gui.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Gui gui, DefaultCraftingDisplay recipe) {
return gui instanceof CraftingTableGui || (gui instanceof PlayerInventoryGui && recipe.getHeight() < 3 && recipe.getWidth() < 3);
}
});
RecipeHelper.registerSpeedCraftFunctional(DefaultPlugin.SMELTING, new SpeedCraftFunctional<DefaultSmeltingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{FurnaceGui.class};
}
@Override
public boolean performAutoCraft(Gui gui, DefaultSmeltingDisplay recipe) {
if (gui instanceof FurnaceGui)
((IMixinRecipeBookGui) (((FurnaceGui) gui).getRecipeBookGui())).getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Gui.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Gui gui, DefaultSmeltingDisplay recipe) {
return gui instanceof FurnaceGui;
}
});
RecipeHelper.registerSpeedCraftFunctional(DefaultPlugin.SMOKING, new SpeedCraftFunctional<DefaultSmokingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{SmokerGui.class};
}
@Override
public boolean performAutoCraft(Gui gui, DefaultSmokingDisplay recipe) {
if (gui instanceof SmokerGui)
((IMixinRecipeBookGui) (((SmokerGui) gui).getRecipeBookGui())).getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Gui.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Gui gui, DefaultSmokingDisplay recipe) {
return gui instanceof SmokerGui;
}
});
RecipeHelper.registerSpeedCraftFunctional(DefaultPlugin.BLASTING, new SpeedCraftFunctional<DefaultBlastingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{BlastFurnaceGui.class};
}
@Override
public boolean performAutoCraft(Gui gui, DefaultBlastingDisplay recipe) {
if (gui instanceof BlastFurnaceGui)
((IMixinRecipeBookGui) (((BlastFurnaceGui) gui).getRecipeBookGui())).getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Gui.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Gui gui, DefaultBlastingDisplay recipe) {
return gui instanceof BlastFurnaceGui;
}
});
}
@Override
public int getPriority() {
return -1;
}
}
|