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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
|
/*
* Roughly Enough Items by Danielshe.
* Licensed under the MIT License.
*/
package me.shedaniel.rei.plugin;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import it.unimi.dsi.fastutil.objects.Object2FloatMap;
import me.shedaniel.math.api.Rectangle;
import me.shedaniel.rei.RoughlyEnoughItemsCore;
import me.shedaniel.rei.api.*;
import me.shedaniel.rei.api.plugins.REIPluginV0;
import me.shedaniel.rei.gui.RecipeViewingScreen;
import me.shedaniel.rei.gui.VillagerRecipeViewingScreen;
import me.shedaniel.rei.gui.widget.CategoryBaseWidget;
import me.shedaniel.rei.impl.ScreenHelper;
import me.shedaniel.rei.plugin.blasting.DefaultBlastingDisplay;
import me.shedaniel.rei.plugin.brewing.DefaultBrewingCategory;
import me.shedaniel.rei.plugin.brewing.DefaultBrewingDisplay;
import me.shedaniel.rei.plugin.campfire.DefaultCampfireCategory;
import me.shedaniel.rei.plugin.campfire.DefaultCampfireDisplay;
import me.shedaniel.rei.plugin.composting.DefaultCompostingCategory;
import me.shedaniel.rei.plugin.composting.DefaultCompostingDisplay;
import me.shedaniel.rei.plugin.cooking.DefaultCookingCategory;
import me.shedaniel.rei.plugin.crafting.DefaultCraftingCategory;
import me.shedaniel.rei.plugin.crafting.DefaultCustomDisplay;
import me.shedaniel.rei.plugin.crafting.DefaultShapedDisplay;
import me.shedaniel.rei.plugin.crafting.DefaultShapelessDisplay;
import me.shedaniel.rei.plugin.smelting.DefaultSmeltingDisplay;
import me.shedaniel.rei.plugin.smoking.DefaultSmokingDisplay;
import me.shedaniel.rei.plugin.stonecutting.DefaultStoneCuttingCategory;
import me.shedaniel.rei.plugin.stonecutting.DefaultStoneCuttingDisplay;
import me.shedaniel.rei.plugin.stripping.DefaultStrippingCategory;
import me.shedaniel.rei.plugin.stripping.DefaultStrippingDisplay;
import me.shedaniel.rei.plugin.stripping.DummyAxeItem;
import net.fabricmc.loader.api.SemanticVersion;
import net.fabricmc.loader.util.version.VersionParsingException;
import net.minecraft.block.ComposterBlock;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.ingame.*;
import net.minecraft.client.gui.screen.recipebook.RecipeBookProvider;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.fluid.EmptyFluid;
import net.minecraft.fluid.Fluid;
import net.minecraft.item.*;
import net.minecraft.potion.PotionUtil;
import net.minecraft.recipe.*;
import net.minecraft.util.Identifier;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.registry.Registry;
import java.util.*;
public class DefaultPlugin implements REIPluginV0 {
public static final Identifier CRAFTING = new Identifier("minecraft", "plugins/crafting");
public static final Identifier SMELTING = new Identifier("minecraft", "plugins/smelting");
public static final Identifier SMOKING = new Identifier("minecraft", "plugins/smoking");
public static final Identifier BLASTING = new Identifier("minecraft", "plugins/blasting");
public static final Identifier CAMPFIRE = new Identifier("minecraft", "plugins/campfire");
public static final Identifier STONE_CUTTING = new Identifier("minecraft", "plugins/stone_cutting");
public static final Identifier STRIPPING = new Identifier("minecraft", "plugins/stripping");
public static final Identifier BREWING = new Identifier("minecraft", "plugins/brewing");
public static final Identifier PLUGIN = new Identifier("roughlyenoughitems", "default_plugin");
public static final Identifier COMPOSTING = new Identifier("minecraft", "plugins/composting");
private static final Identifier DISPLAY_TEXTURE = new Identifier("roughlyenoughitems", "textures/gui/display.png");
private static final Identifier DISPLAY_TEXTURE_DARK = new Identifier("roughlyenoughitems", "textures/gui/display_dark.png");
private static final List<DefaultBrewingDisplay> BREWING_DISPLAYS = Lists.newArrayList();
public static Identifier getDisplayTexture() {
return ScreenHelper.isDarkModeEnabled() ? DISPLAY_TEXTURE_DARK : DISPLAY_TEXTURE;
}
public static void registerBrewingDisplay(DefaultBrewingDisplay display) {
BREWING_DISPLAYS.add(display);
}
@Override
public Identifier getPluginIdentifier() {
return PLUGIN;
}
@Override
public SemanticVersion getMinimumVersion() throws VersionParsingException {
return SemanticVersion.parse("3.0-pre");
}
@Override
public void registerEntries(EntryRegistry entryRegistry) {
if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
return;
}
for (Item item : Registry.ITEM) {
ItemStack[] stacks = null;
try {
stacks = entryRegistry.getAllStacksFromItem(item);
for (ItemStack stack : entryRegistry.getAllStacksFromItem(item)) {
entryRegistry.registerEntry(EntryStack.create(stack));
}
} catch (Exception ignored) {
}
if (stacks != null) {
for (ItemStack stack : entryRegistry.getAllStacksFromItem(item)) {
entryRegistry.registerEntry(EntryStack.create(stack));
}
} else entryRegistry.registerEntry(EntryStack.create(item));
}
EntryStack stack = EntryStack.create(Items.ENCHANTED_BOOK);
for (Enchantment enchantment : Registry.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);
entryRegistry.registerEntriesAfter(stack, EntryStack.create(itemStack));
}
}
for (Fluid fluid : Registry.FLUID) {
if (!(fluid instanceof EmptyFluid))
entryRegistry.registerEntry(EntryStack.create(fluid));
}
}
@Override
public void registerPluginCategories(RecipeHelper recipeHelper) {
if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
return;
}
recipeHelper.registerCategory(new DefaultCraftingCategory());
recipeHelper.registerCategory(new DefaultCookingCategory(SMELTING, EntryStack.create(Items.FURNACE), "category.rei.smelting"));
recipeHelper.registerCategory(new DefaultCookingCategory(SMOKING, EntryStack.create(Items.SMOKER), "category.rei.smoking"));
recipeHelper.registerCategory(new DefaultCookingCategory(BLASTING, EntryStack.create(Items.BLAST_FURNACE), "category.rei.blasting"));
recipeHelper.registerCategory(new DefaultCampfireCategory());
recipeHelper.registerCategory(new DefaultStoneCuttingCategory());
recipeHelper.registerCategory(new DefaultBrewingCategory());
recipeHelper.registerCategory(new DefaultCompostingCategory());
recipeHelper.registerCategory(new DefaultStrippingCategory());
}
@Override
public void registerRecipeDisplays(RecipeHelper recipeHelper) {
if (!ConfigObject.getInstance().isLoadingDefaultPlugin()) {
return;
}
recipeHelper.registerRecipes(CRAFTING, ShapelessRecipe.class, DefaultShapelessDisplay::new);
recipeHelper.registerRecipes(CRAFTING, ShapedRecipe.class, DefaultShapedDisplay::new);
recipeHelper.registerRecipes(SMELTING, SmeltingRecipe.class, DefaultSmeltingDisplay::new);
recipeHelper.registerRecipes(SMOKING, SmokingRecipe.class, DefaultSmokingDisplay::new);
recipeHelper.registerRecipes(BLASTING, BlastingRecipe.class, DefaultBlastingDisplay::new);
recipeHelper.registerRecipes(CAMPFIRE, CampfireCookingRecipe.class, DefaultCampfireDisplay::new);
recipeHelper.registerRecipes(STONE_CUTTING, StonecuttingRecipe.class, DefaultStoneCuttingDisplay::new);
for (DefaultBrewingDisplay display : BREWING_DISPLAYS) {
recipeHelper.registerDisplay(BREWING, display);
}
List<EntryStack> arrowStack = Collections.singletonList(EntryStack.create(Items.ARROW));
for (EntryStack entry : EntryRegistry.getInstance().getStacksList()) {
if (entry.getItem() == Items.LINGERING_POTION) {
List<List<EntryStack>> input = new ArrayList<>();
for (int i = 0; i < 4; i++)
input.add(arrowStack);
input.add(Collections.singletonList(EntryStack.create(entry.getItemStack())));
for (int i = 0; i < 4; i++)
input.add(arrowStack);
ItemStack outputStack = new ItemStack(Items.TIPPED_ARROW, 8);
PotionUtil.setPotion(outputStack, PotionUtil.getPotion(entry.
|