diff --git a/build.gradle.kts b/build.gradle.kts index 07b604b..546ae08 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ plugins { - id("net.somethingcatchy.gradle") version ("0.0.7") + id("com.possible-triangle.gradle") version ("0.1.0") } subprojects { diff --git a/common/build.gradle.kts b/common/build.gradle.kts index 79086bf..eaad495 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -15,7 +15,7 @@ dependencies { "mappings"(loom.officialMojangMappings()) modCompileOnly("com.tterrag.registrate_fabric:Registrate:${registrate_fabric_version}") - modCompileOnly("mezz.jei:jei-${mc_version}-common-api:${jei_version}") + //modCompileOnly("mezz.jei:jei-${mc_version}-common-api:${jei_version}") } tasks.register("prepareWorkspace") { diff --git a/common/src/main/java/galena/blissful/compat/BlissfulJeiCompat.java b/common/src/main/java/galena/blissful/compat/BlissfulJeiCompat.java new file mode 100644 index 0000000..7e48c39 --- /dev/null +++ b/common/src/main/java/galena/blissful/compat/BlissfulJeiCompat.java @@ -0,0 +1,19 @@ +package galena.blissful.compat; + +import galena.blissful.BlissfulConstants; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.world.item.ItemStack; +import net.minecraft.world.item.alchemy.PotionUtils; + +public class BlissfulJeiCompat { + + public static final ResourceLocation ID = new ResourceLocation(BlissfulConstants.MOD_ID, "jei"); + + public static String interpretPotion(ItemStack ingredient, Object unused) { + var potion = PotionUtils.getPotion(ingredient); + var effects = PotionUtils.getMobEffects(ingredient); + var builder = new StringBuilder(potion.getName("")); + effects.forEach(it -> builder.append(";").append(it)); + return builder.toString(); + } +} diff --git a/common/src/main/java/galena/blissful/compat/BlissfulJeiPlugin.java b/common/src/main/java/galena/blissful/compat/BlissfulJeiPlugin.java deleted file mode 100644 index d2dd509..0000000 --- a/common/src/main/java/galena/blissful/compat/BlissfulJeiPlugin.java +++ /dev/null @@ -1,33 +0,0 @@ -package galena.blissful.compat; - -import galena.blissful.BlissfulConstants; -import galena.blissful.index.BlissfuItems; -import mezz.jei.api.IModPlugin; -import mezz.jei.api.ingredients.subtypes.IIngredientSubtypeInterpreter; -import mezz.jei.api.registration.ISubtypeRegistration; -import net.minecraft.resources.ResourceLocation; -import net.minecraft.world.item.ItemStack; -import net.minecraft.world.item.alchemy.PotionUtils; - -public class BlissfulJeiPlugin implements IModPlugin { - - private static final ResourceLocation ID = new ResourceLocation(BlissfulConstants.MOD_ID, "jei"); - - private static final IIngredientSubtypeInterpreter POTION_INTERPRETER = (ingredient, context) -> { - var potion = PotionUtils.getPotion(ingredient); - var effects = PotionUtils.getMobEffects(ingredient); - var builder = new StringBuilder(potion.getName("")); - effects.forEach(it -> builder.append(";").append(it)); - return builder.toString(); - }; - - @Override - public ResourceLocation getPluginUid() { - return ID; - } - - @Override - public void registerItemSubtypes(ISubtypeRegistration registration) { - registration.registerSubtypeInterpreter(BlissfuItems.POTION_BONG.get(), POTION_INTERPRETER); - } -} diff --git a/fabric/src/main/java/galena/blissful/fabric/compat/BlissfulJeiFabricPlugin.java b/fabric/src/main/java/galena/blissful/fabric/compat/BlissfulJeiFabricPlugin.java new file mode 100644 index 0000000..15ce1d2 --- /dev/null +++ b/fabric/src/main/java/galena/blissful/fabric/compat/BlissfulJeiFabricPlugin.java @@ -0,0 +1,21 @@ +package galena.blissful.fabric.compat; + +import galena.blissful.compat.BlissfulJeiCompat; +import galena.blissful.index.BlissfuItems; +import mezz.jei.api.IModPlugin; +import mezz.jei.api.registration.ISubtypeRegistration; +import net.minecraft.resources.ResourceLocation; + +public class BlissfulJeiFabricPlugin implements IModPlugin { + + @Override + public ResourceLocation getPluginUid() { + return BlissfulJeiCompat.ID; + } + + @Override + public void registerItemSubtypes(ISubtypeRegistration registration) { + registration.registerSubtypeInterpreter(BlissfuItems.POTION_BONG.get(), BlissfulJeiCompat::interpretPotion); + } + +} diff --git a/fabric/src/main/resources/fabric.mod.json b/fabric/src/main/resources/fabric.mod.json index 0df14bd..7881f41 100644 --- a/fabric/src/main/resources/fabric.mod.json +++ b/fabric/src/main/resources/fabric.mod.json @@ -14,7 +14,7 @@ "entrypoints": { "main": ["galena.blissful.fabric.FabricEntrypoint"], "fabric-datagen": ["galena.blissful.fabric.datagen.FabricDataGenerators"], - "jei_mod_plugin": ["galena.blissful.compat.BlissfulJeiPlugin"] + "jei_mod_plugin": ["galena.blissful.fabric.compat.BlissfulJeiFabricPlugin"] }, "mixins": ["${mod_id}.mixins.json", "${mod_id}.fabric.mixins.json"], "depends": { diff --git a/forge/src/main/java/galena/blissful/forge/compat/BlissfulForgeJeiPlugin.java b/forge/src/main/java/galena/blissful/forge/compat/BlissfulForgeJeiPlugin.java index 644ca73..14315c1 100644 --- a/forge/src/main/java/galena/blissful/forge/compat/BlissfulForgeJeiPlugin.java +++ b/forge/src/main/java/galena/blissful/forge/compat/BlissfulForgeJeiPlugin.java @@ -1,18 +1,32 @@ package galena.blissful.forge.compat; -import galena.blissful.compat.BlissfulJeiPlugin; +import galena.blissful.compat.BlissfulJeiCompat; +import galena.blissful.index.BlissfuItems; +import mezz.jei.api.IModPlugin; import mezz.jei.api.JeiPlugin; import mezz.jei.api.registration.IRecipeRegistration; +import mezz.jei.api.registration.ISubtypeRegistration; +import net.minecraft.resources.ResourceLocation; import net.minecraftforge.fml.ModList; @JeiPlugin -public class BlissfulForgeJeiPlugin extends BlissfulJeiPlugin { +public class BlissfulForgeJeiPlugin implements IModPlugin { @Override public void registerRecipes(IRecipeRegistration registration) { - if(ModList.get().isLoaded("create")) { + if (ModList.get().isLoaded("create")) { CreateCompat.addJeiRecipes(registration); } } + @Override + public ResourceLocation getPluginUid() { + return BlissfulJeiCompat.ID; + } + + @Override + public void registerItemSubtypes(ISubtypeRegistration registration) { + registration.registerSubtypeInterpreter(BlissfuItems.POTION_BONG.get(), BlissfulJeiCompat::interpretPotion); + } + }