Skip to content

Commit

Permalink
move jei plugins to platform modules
Browse files Browse the repository at this point in the history
  • Loading branch information
PssbleTrngle committed Sep 6, 2023
1 parent ef13fd0 commit 326d7bd
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 39 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id("net.somethingcatchy.gradle") version ("0.0.7")
id("com.possible-triangle.gradle") version ("0.1.0")
}

subprojects {
Expand Down
2 changes: 1 addition & 1 deletion common/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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") {
Expand Down
19 changes: 19 additions & 0 deletions common/src/main/java/galena/blissful/compat/BlissfulJeiCompat.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
33 changes: 0 additions & 33 deletions common/src/main/java/galena/blissful/compat/BlissfulJeiPlugin.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -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);
}

}
2 changes: 1 addition & 1 deletion fabric/src/main/resources/fabric.mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}

}

0 comments on commit 326d7bd

Please sign in to comment.