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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
|
package me.shedaniel.rei.plugin;
import com.google.common.collect.Lists;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.*;
import me.shedaniel.rei.client.RecipeHelper;
import me.shedaniel.rei.listeners.IMixinRecipeBookGui;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.Screen;
import net.minecraft.client.gui.container.BlastFurnaceScreen;
import net.minecraft.client.gui.container.CraftingTableScreen;
import net.minecraft.client.gui.container.FurnaceScreen;
import net.minecraft.client.gui.container.SmokerScreen;
import net.minecraft.client.gui.ingame.PlayerInventoryScreen;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.item.ItemStack;
import net.minecraft.item.Items;
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 net.minecraft.util.registry.Registry;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
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 onFirstLoad(IPluginDisabler pluginDisabler) {
if (!RoughlyEnoughItemsCore.getConfigHelper().isLoadingDefaultPlugin()) {
pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_ITEMS);
pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_CATEGORIES);
pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_RECIPE_DISPLAYS);
pluginDisabler.disablePluginFunction(new Identifier("roughlyenoughitems", "default_plugin"), PluginFunction.REGISTER_SPEED_CRAFT);
}
}
@Override
public void registerItems(IItemRegisterer itemRegisterer) {
Registry.ITEM.stream().forEach(item -> {
itemRegisterer.registerItemStack(item.getDefaultStack());
try {
itemRegisterer.registerItemStack(itemRegisterer.getAllStacksFromItem(item));
} catch (Exception e) {
}
});
Registry.ENCHANTMENT.forEach(enchantment -> {
for(int i = enchantment.getMinimumLevel(); i < enchantment.getMaximumLevel(); i++) {
Map<Enchantment, Integer> map = new HashMap<>();
map.put(enchantment, i);
ItemStack itemStack = new ItemStack(Items.ENCHANTED_BOOK);
EnchantmentHelper.set(map, itemStack);
itemRegisterer.registerItemStack(Items.ENCHANTED_BOOK, itemStack);
}
});
}
@Override
public void registerPluginCategories(RecipeHelper recipeHelper) {
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 registerRecipeDisplays(RecipeHelper recipeHelper) {
for(Recipe recipe : recipeHelper.getRecipeManager().values())
if (recipe instanceof ShapelessRecipe)
recipeHelper.registerDisplay(CRAFTING, new DefaultShapelessDisplay((ShapelessRecipe) recipe));
else if (recipe instanceof ShapedRecipe)
recipeHelper.registerDisplay(CRAFTING, new DefaultShapedDisplay((ShapedRecipe) recipe));
else if (recipe instanceof SmeltingRecipe)
recipeHelper.registerDisplay(SMELTING, new DefaultSmeltingDisplay((SmeltingRecipe) recipe));
else if (recipe instanceof SmokingRecipe)
recipeHelper.registerDisplay(SMOKING, new DefaultSmokingDisplay((SmokingRecipe) recipe));
else if (recipe instanceof BlastingRecipe)
recipeHelper.registerDisplay(BLASTING, new DefaultBlastingDisplay((BlastingRecipe) recipe));
else if (recipe instanceof CampfireCookingRecipe)
recipeHelper.registerDisplay(CAMPFIRE, new DefaultCampfireDisplay((CampfireCookingRecipe) recipe));
else if (recipe instanceof StonecuttingRecipe)
recipeHelper.registerDisplay(STONE_CUTTING, new DefaultStoneCuttingDisplay((StonecuttingRecipe) recipe));
BREWING_DISPLAYS.stream().forEachOrdered(display -> recipeHelper.registerDisplay(BREWING, display));
}
@Override
public void registerSpeedCraft(RecipeHelper recipeHelper) {
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[]{PlayerInventoryScreen.class, CraftingTableScreen.class};
}
@Override
public boolean performAutoCraft(Screen screen, DefaultCraftingDisplay recipe) {
if (screen.getClass().isAssignableFrom(CraftingTableScreen.class))
((IMixinRecipeBookGui) (((CraftingTableScreen) screen).getRecipeBookGui())).rei_getGhostSlots().reset();
else if (screen.getClass().isAssignableFrom(PlayerInventoryScreen.class))
((IMixinRecipeBookGui) (((PlayerInventoryScreen) screen).getRecipeBookGui())).rei_getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Screen.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Screen screen, DefaultCraftingDisplay recipe) {
return screen instanceof CraftingTableScreen || (screen instanceof PlayerInventoryScreen && recipe.getHeight() < 3 && recipe.getWidth() < 3);
}
});
recipeHelper.registerSpeedCraftFunctional(DefaultPlugin.SMELTING, new SpeedCraftFunctional<DefaultSmeltingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{FurnaceScreen.class};
}
@Override
public boolean performAutoCraft(Screen screen, DefaultSmeltingDisplay recipe) {
if (screen instanceof FurnaceScreen)
((IMixinRecipeBookGui) (((FurnaceScreen) screen).getRecipeBookGui())).rei_getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Screen.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Screen screen, DefaultSmeltingDisplay recipe) {
return screen instanceof FurnaceScreen;
}
});
recipeHelper.registerSpeedCraftFunctional(DefaultPlugin.SMOKING, new SpeedCraftFunctional<DefaultSmokingDisplay>() {
@Override
public Class[] getFunctioningFor() {
return new Class[]{SmokerScreen.class};
}
@Override
public boolean performAutoCraft(Screen screen, DefaultSmokingDisplay recipe) {
if (screen instanceof SmokerScreen)
((IMixinRecipeBookGui) (((SmokerScreen) screen).getRecipeBookGui())).rei_getGhostSlots().reset();
else
return false;
MinecraftClient.getInstance().interactionManager.clickRecipe(MinecraftClient.getInstance().player.container.syncId, recipe.getRecipe(), Screen.isShiftPressed());
return true;
}
@Override
public boolean acceptRecipe(Screen screen, DefaultSmokingDisplay recipe) {
return screen instanceof SmokerScreen;
}
});
recipeHelper.registerSpeedCraftFunctional(DefaultPlugin.BLASTING, new SpeedCraftFunctional<DefaultBlastingDisplay>() {
@Override
public Class[] getFunctioningFor()<
|