|
1 | | -//package mrbysco.constructionstick.integrations.jei; |
2 | | -// |
3 | | -//import mezz.jei.api.IModPlugin; |
4 | | -//import mezz.jei.api.JeiPlugin; |
5 | | -//import mezz.jei.api.constants.VanillaTypes; |
6 | | -//import mezz.jei.api.recipe.category.extensions.vanilla.smithing.IExtendableSmithingRecipeCategory; |
7 | | -//import mezz.jei.api.registration.IIngredientAliasRegistration; |
8 | | -//import mezz.jei.api.registration.IRecipeRegistration; |
9 | | -//import mezz.jei.api.registration.IVanillaCategoryExtensionRegistration; |
10 | | -//import mrbysco.constructionstick.ConstructionStick; |
11 | | -//import mrbysco.constructionstick.client.KeybindHandler; |
12 | | -//import mrbysco.constructionstick.config.ConstructionConfig; |
13 | | -//import mrbysco.constructionstick.config.ConstructionConfig.StickProperties; |
14 | | -//import mrbysco.constructionstick.integrations.jei.category.UpgradeCategory; |
15 | | -//import mrbysco.constructionstick.items.stick.ItemStick; |
16 | | -//import mrbysco.constructionstick.items.template.ItemUpgradeTemplate; |
17 | | -//import mrbysco.constructionstick.recipe.SmithingApplyUpgradeRecipe; |
18 | | -//import mrbysco.constructionstick.registry.ModItems; |
19 | | -//import net.minecraft.ChatFormatting; |
20 | | -//import net.minecraft.core.registries.BuiltInRegistries; |
21 | | -//import net.minecraft.network.chat.Component; |
22 | | -//import net.minecraft.network.chat.MutableComponent; |
23 | | -//import net.minecraft.resources.ResourceLocation; |
24 | | -//import net.minecraft.world.item.Item; |
25 | | -//import net.minecraft.world.item.ItemStack; |
26 | | -//import net.neoforged.neoforge.registries.DeferredItem; |
27 | | -//import org.jetbrains.annotations.NotNull; |
28 | | -// |
29 | | -//import java.util.List; |
30 | | -// |
31 | | -//@JeiPlugin |
32 | | -//public class ConstructionStickJeiPlugin implements IModPlugin { |
33 | | -// private static final ResourceLocation pluginId = ConstructionStick.modLoc(ConstructionStick.MOD_ID); |
34 | | -// private static final String baseKey = ConstructionStick.MOD_ID + ".description."; |
35 | | -// private static final String baseKeyItem = "item." + ConstructionStick.MOD_ID + "."; |
36 | | -// |
37 | | -// @NotNull |
38 | | -// @Override |
39 | | -// public ResourceLocation getPluginUid() { |
40 | | -// return pluginId; |
41 | | -// } |
42 | | -// |
43 | | -// @Override |
44 | | -// public void registerVanillaCategoryExtensions(IVanillaCategoryExtensionRegistration registration) { |
45 | | -// IExtendableSmithingRecipeCategory smithingCategory = registration.getSmithingCategory(); |
46 | | -// smithingCategory.addExtension(SmithingApplyUpgradeRecipe.class, new UpgradeCategory()); |
47 | | -// } |
48 | | -// |
49 | | -// @Override |
50 | | -// public void registerRecipes(@NotNull IRecipeRegistration registration) { |
51 | | -// |
52 | | -// MutableComponent stickChangeUpgradeKey = Component.translatable(KeybindHandler.KEY_CHANGE_UPGRADE.getName()).withStyle(ChatFormatting.BLUE); |
53 | | -// MutableComponent stickOpenGuiKey = Component.translatable(KeybindHandler.KEY_OPEN_GUI.getName()).withStyle(ChatFormatting.BLUE); |
54 | | -// MutableComponent stickUndoKey = Component.translatable(KeybindHandler.KEY_UNDO.getName()).withStyle(ChatFormatting.BLUE); |
55 | | -// MutableComponent stickShowPrevious = Component.translatable(KeybindHandler.KEY_SHOW_PREVIOUS.getName()).withStyle(ChatFormatting.BLUE); |
56 | | -// |
57 | | -// for (DeferredItem<ItemStick> deferredStick : ModItems.STICKS) { |
58 | | -// Item stick = deferredStick.get(); |
59 | | -// StickProperties stickProperties = ConstructionConfig.getStickProperties(stick); |
60 | | -// |
61 | | -// Component durabilityComponent = Component.translatable(baseKey + "durability.limited", stickProperties.getDurability()); |
62 | | -// |
63 | | -// registration.addIngredientInfo(new ItemStack(stick), VanillaTypes.ITEM_STACK, |
64 | | -// Component.translatable(baseKey + "stick", |
65 | | -// Component.translatable(baseKeyItem + BuiltInRegistries.ITEM.getKey(stick).getPath()), |
66 | | -// stickProperties.getLimit(), durabilityComponent, stickChangeUpgradeKey, stickOpenGuiKey, stickShowPrevious, stickUndoKey, stickOpenGuiKey) |
67 | | -// ); |
68 | | -// } |
69 | | -// |
70 | | -// for (DeferredItem<ItemUpgradeTemplate> templateSupplier : ModItems.TEMPLATES) { |
71 | | -// Item upgradeTemplate = templateSupplier.get(); |
72 | | -// registration.addIngredientInfo(new ItemStack(upgradeTemplate), VanillaTypes.ITEM_STACK, |
73 | | -// Component.translatable(baseKey + BuiltInRegistries.ITEM.getKey(upgradeTemplate).getPath()) |
74 | | -// .append("\n\n") |
75 | | -// .append(Component.translatable(baseKey + "upgrade", stickChangeUpgradeKey)) |
76 | | -// ); |
77 | | -// } |
78 | | -// } |
79 | | -// |
80 | | -// @Override |
81 | | -// public void registerIngredientAliases(IIngredientAliasRegistration registration) { |
82 | | -// for (DeferredItem<ItemStick> deferredStick : ModItems.STICKS) { |
83 | | -// registration.addAliases(VanillaTypes.ITEM_STACK, deferredStick.toStack(), List.of("construction", "wand", "construction wand")); |
84 | | -// } |
85 | | -// } |
86 | | -//} |
| 1 | +package mrbysco.constructionstick.integrations.jei; |
| 2 | + |
| 3 | +import mezz.jei.api.IModPlugin; |
| 4 | +import mezz.jei.api.JeiPlugin; |
| 5 | +import mezz.jei.api.constants.VanillaTypes; |
| 6 | +import mezz.jei.api.recipe.category.extensions.vanilla.smithing.IExtendableSmithingRecipeCategory; |
| 7 | +import mezz.jei.api.registration.IIngredientAliasRegistration; |
| 8 | +import mezz.jei.api.registration.IRecipeRegistration; |
| 9 | +import mezz.jei.api.registration.IVanillaCategoryExtensionRegistration; |
| 10 | +import mrbysco.constructionstick.ConstructionStick; |
| 11 | +import mrbysco.constructionstick.client.KeybindHandler; |
| 12 | +import mrbysco.constructionstick.config.ConstructionConfig; |
| 13 | +import mrbysco.constructionstick.config.ConstructionConfig.StickProperties; |
| 14 | +import mrbysco.constructionstick.integrations.jei.category.UpgradeCategory; |
| 15 | +import mrbysco.constructionstick.items.stick.ItemStick; |
| 16 | +import mrbysco.constructionstick.items.template.ItemUpgradeTemplate; |
| 17 | +import mrbysco.constructionstick.recipe.SmithingApplyUpgradeRecipe; |
| 18 | +import mrbysco.constructionstick.registry.ModItems; |
| 19 | +import net.minecraft.ChatFormatting; |
| 20 | +import net.minecraft.core.registries.BuiltInRegistries; |
| 21 | +import net.minecraft.network.chat.Component; |
| 22 | +import net.minecraft.network.chat.MutableComponent; |
| 23 | +import net.minecraft.resources.ResourceLocation; |
| 24 | +import net.minecraft.world.item.Item; |
| 25 | +import net.minecraft.world.item.ItemStack; |
| 26 | +import net.minecraftforge.registries.RegistryObject; |
| 27 | +import org.jetbrains.annotations.NotNull; |
| 28 | + |
| 29 | +import java.util.List; |
| 30 | + |
| 31 | +@JeiPlugin |
| 32 | +public class ConstructionStickJeiPlugin implements IModPlugin { |
| 33 | + private static final ResourceLocation pluginId = ConstructionStick.modLoc(ConstructionStick.MOD_ID); |
| 34 | + private static final String baseKey = ConstructionStick.MOD_ID + ".description."; |
| 35 | + private static final String baseKeyItem = "item." + ConstructionStick.MOD_ID + "."; |
| 36 | + |
| 37 | + @NotNull |
| 38 | + @Override |
| 39 | + public ResourceLocation getPluginUid() { |
| 40 | + return pluginId; |
| 41 | + } |
| 42 | + |
| 43 | + @Override |
| 44 | + public void registerVanillaCategoryExtensions(IVanillaCategoryExtensionRegistration registration) { |
| 45 | + IExtendableSmithingRecipeCategory smithingCategory = registration.getSmithingCategory(); |
| 46 | + smithingCategory.addExtension(SmithingApplyUpgradeRecipe.class, new UpgradeCategory()); |
| 47 | + } |
| 48 | + |
| 49 | + @Override |
| 50 | + public void registerRecipes(@NotNull IRecipeRegistration registration) { |
| 51 | + |
| 52 | + MutableComponent stickChangeUpgradeKey = Component.translatable(KeybindHandler.KEY_CHANGE_UPGRADE.getName()).withStyle(ChatFormatting.BLUE); |
| 53 | + MutableComponent stickOpenGuiKey = Component.translatable(KeybindHandler.KEY_OPEN_GUI.getName()).withStyle(ChatFormatting.BLUE); |
| 54 | + MutableComponent stickUndoKey = Component.translatable(KeybindHandler.KEY_UNDO.getName()).withStyle(ChatFormatting.BLUE); |
| 55 | + MutableComponent stickShowPrevious = Component.translatable(KeybindHandler.KEY_SHOW_PREVIOUS.getName()).withStyle(ChatFormatting.BLUE); |
| 56 | + |
| 57 | + for (RegistryObject<ItemStick> deferredStick : ModItems.STICKS) { |
| 58 | + Item stick = deferredStick.get(); |
| 59 | + StickProperties stickProperties = ConstructionConfig.getStickProperties(stick); |
| 60 | + |
| 61 | + Component durabilityComponent = Component.translatable(baseKey + "durability.limited", stickProperties.getDurability()); |
| 62 | + |
| 63 | + registration.addIngredientInfo(new ItemStack(stick), VanillaTypes.ITEM_STACK, |
| 64 | + Component.translatable(baseKey + "stick", |
| 65 | + Component.translatable(baseKeyItem + BuiltInRegistries.ITEM.getKey(stick).getPath()), |
| 66 | + stickProperties.getLimit(), durabilityComponent, stickChangeUpgradeKey, stickOpenGuiKey, stickShowPrevious, stickUndoKey, stickOpenGuiKey) |
| 67 | + ); |
| 68 | + } |
| 69 | + |
| 70 | + for (RegistryObject<ItemUpgradeTemplate> templateSupplier : ModItems.TEMPLATES) { |
| 71 | + Item upgradeTemplate = templateSupplier.get(); |
| 72 | + registration.addIngredientInfo(new ItemStack(upgradeTemplate), VanillaTypes.ITEM_STACK, |
| 73 | + Component.translatable(baseKey + BuiltInRegistries.ITEM.getKey(upgradeTemplate).getPath()) |
| 74 | + .append("\n\n") |
| 75 | + .append(Component.translatable(baseKey + "upgrade", stickChangeUpgradeKey)) |
| 76 | + ); |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + @Override |
| 81 | + public void registerIngredientAliases(IIngredientAliasRegistration registration) { |
| 82 | + for (RegistryObject<ItemStick> deferredStick : ModItems.STICKS) { |
| 83 | + registration.addAliases(VanillaTypes.ITEM_STACK, deferredStick.get().getDefaultInstance(), List.of("construction", "wand", "construction wand")); |
| 84 | + } |
| 85 | + } |
| 86 | +} |
0 commit comments