From f0184f4d1a91d683046bebfab42b66962b375073 Mon Sep 17 00:00:00 2001 From: Flanks255 <32142731+Flanks255@users.noreply.github.com> Date: Wed, 13 Mar 2024 17:42:12 -0500 Subject: [PATCH] Added charged versions of all Energy items to JEI --- .../actuallyadditions/mod/ActuallyAdditions.java | 2 -- .../actuallyadditions/mod/ActuallyTabs.java | 3 ++- .../mod/jei/JEIActuallyAdditionsPlugin.java | 16 ++++++++++++---- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java index 607d75c8c..987dc9992 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyAdditions.java @@ -163,10 +163,8 @@ public class ActuallyAdditions { new UpdateChecker(); InitEntities.init(); // todo: [port] replace - //AAWorldGen gen = new AAWorldGen(); ItemCoffee.initIngredients(); CrusherCrafting.init(); - //LensMining.init(); } private void onConfigReload(ModConfigEvent event) { diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java index dd77874b8..949548aae 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/ActuallyTabs.java @@ -19,7 +19,7 @@ import java.util.stream.Collectors; public class ActuallyTabs { public static final DeferredRegister CREATIVE_MODE_TABS = DeferredRegister.create(Registries.CREATIVE_MODE_TAB, ActuallyAdditions.MODID); - public static final Supplier GROUP = CREATIVE_MODE_TABS.register("tab", () -> CreativeModeTab.builder() + public static final Supplier GROUP = CREATIVE_MODE_TABS.register("tab", () -> CreativeModeTab.builder() // TODO coherently order them :P .icon(() -> ActuallyItems.ITEM_BOOKLET.get().getDefaultInstance()) .withTabsBefore(CreativeModeTabs.SPAWN_EGGS) .title(Component.translatable("itemGroup.actuallyadditions")) @@ -34,6 +34,7 @@ public class ActuallyTabs { CustomEnergyStorage storage = new CustomEnergyStorage(itemEnergy.maxPower, itemEnergy.transfer, itemEnergy.transfer); storage.setEnergyStored(itemEnergy.maxPower); stack.setData(ActuallyAttachments.ENERGY_STORAGE.get(), storage); + stack.getOrCreateTag().putBoolean("Charged", true); } }); stacks.addAll(charged); diff --git a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java index 0ff768d6f..1415452bd 100644 --- a/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java +++ b/src/main/java/de/ellpeck/actuallyadditions/mod/jei/JEIActuallyAdditionsPlugin.java @@ -17,6 +17,7 @@ import de.ellpeck.actuallyadditions.mod.inventory.gui.CrusherScreen; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiCoffeeMachine; import de.ellpeck.actuallyadditions.mod.inventory.gui.GuiFurnaceDouble; import de.ellpeck.actuallyadditions.mod.items.ActuallyItems; +import de.ellpeck.actuallyadditions.mod.items.base.ItemEnergy; import de.ellpeck.actuallyadditions.mod.jei.coffee.CoffeeMachineCategory; import de.ellpeck.actuallyadditions.mod.jei.crusher.CrusherCategory; import de.ellpeck.actuallyadditions.mod.jei.empowerer.EmpowererRecipeCategory; @@ -29,16 +30,15 @@ import mezz.jei.api.JeiPlugin; import mezz.jei.api.constants.RecipeTypes; import mezz.jei.api.helpers.IJeiHelpers; import mezz.jei.api.recipe.RecipeType; -import mezz.jei.api.registration.IGuiHandlerRegistration; -import mezz.jei.api.registration.IRecipeCatalystRegistration; -import mezz.jei.api.registration.IRecipeCategoryRegistration; -import mezz.jei.api.registration.IRecipeRegistration; +import mezz.jei.api.registration.*; import net.minecraft.client.Minecraft; import net.minecraft.resources.ResourceLocation; import net.minecraft.world.item.ItemStack; import net.minecraft.world.item.crafting.RecipeHolder; import net.minecraft.world.level.Level; +import javax.annotation.Nonnull; + @JeiPlugin public class JEIActuallyAdditionsPlugin implements IModPlugin { public static final ResourceLocation ID = new ResourceLocation(ActuallyAdditions.MODID, "jei_plugin"); @@ -55,6 +55,14 @@ public class JEIActuallyAdditionsPlugin implements IModPlugin { public static final RecipeType CRUSHING = RecipeType.create(ActuallyAdditions.MODID, "crushing", CrushingRecipe.class); public static final RecipeType MINING_LENS = RecipeType.create(ActuallyAdditions.MODID, "mining_lens", MiningLensRecipe.class); + @Override + public void registerItemSubtypes(@Nonnull ISubtypeRegistration reg) { + ActuallyItems.ITEMS.getEntries().forEach(entry -> { + if (entry.get() instanceof ItemEnergy) + reg.useNbtForSubtypes(entry.get()); + }); + } + @Override public void registerCategories(IRecipeCategoryRegistration registry) { IJeiHelpers helpers = registry.getJeiHelpers();