-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for Chemicals to ae2jeiintegration
This allows using Mekanism Chemicals for Patterns and Filters with JEI when using the ae2jeiintegration mod.
- Loading branch information
Showing
6 changed files
with
117 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/me/ramidzkh/mekae2/integration/jei/AE2JeiIntegrationHelper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package me.ramidzkh.mekae2.integration.jei; | ||
|
||
import tamaized.ae2jeiintegration.api.integrations.jei.IngredientConverters; | ||
|
||
public class AE2JeiIntegrationHelper { | ||
public static void register() { | ||
IngredientConverters.register(new ChemicalIngredientConverter()); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
src/main/java/me/ramidzkh/mekae2/integration/jei/AMJeiPlugin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package me.ramidzkh.mekae2.integration.jei; | ||
|
||
import me.ramidzkh.mekae2.AppliedMekanistics; | ||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.JeiPlugin; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.neoforged.fml.ModList; | ||
import net.neoforged.fml.loading.LoadingModList; | ||
import net.neoforged.fml.loading.moddiscovery.ModInfo; | ||
|
||
@JeiPlugin | ||
public class AMJeiPlugin implements IModPlugin { | ||
@Override | ||
public ResourceLocation getPluginUid() { | ||
return ResourceLocation.fromNamespaceAndPath(AppliedMekanistics.ID, "jei_plugin"); | ||
} | ||
|
||
public AMJeiPlugin() { | ||
if (isModLoaded("ae2jeiintegration")) { | ||
AE2JeiIntegrationHelper.register(); | ||
} | ||
} | ||
|
||
private static boolean isModLoaded(String modId) { | ||
if (ModList.get() == null) { | ||
return LoadingModList.get().getMods().stream().map(ModInfo::getModId).anyMatch(modId::equals); | ||
} | ||
return ModList.get().isLoaded(modId); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/me/ramidzkh/mekae2/integration/jei/ChemicalIngredientConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package me.ramidzkh.mekae2.integration.jei; | ||
|
||
import appeng.api.stacks.GenericStack; | ||
import me.ramidzkh.mekae2.ae2.MekanismKey; | ||
import mekanism.api.IMekanismAccess; | ||
import mekanism.api.chemical.ChemicalStack; | ||
import mekanism.api.integration.jei.IMekanismJEIHelper; | ||
import mezz.jei.api.ingredients.IIngredientHelper; | ||
import mezz.jei.api.ingredients.IIngredientType; | ||
import org.jetbrains.annotations.Nullable; | ||
import tamaized.ae2jeiintegration.api.integrations.jei.IngredientConverter; | ||
|
||
public class ChemicalIngredientConverter implements IngredientConverter<ChemicalStack> { | ||
private final IIngredientType<ChemicalStack> ingredientType; | ||
|
||
public ChemicalIngredientConverter() { | ||
IMekanismJEIHelper mekJeiHelper = IMekanismAccess.INSTANCE.jeiHelper(); | ||
IIngredientHelper<ChemicalStack> chemicalStackHelper = mekJeiHelper.getChemicalStackHelper(); | ||
this.ingredientType = chemicalStackHelper.getIngredientType(); | ||
} | ||
|
||
@Override | ||
public IIngredientType<ChemicalStack> getIngredientType() { | ||
return ingredientType; | ||
} | ||
|
||
@Override | ||
public @Nullable ChemicalStack getIngredientFromStack(GenericStack genericStack) { | ||
if (genericStack.what() instanceof MekanismKey key) { | ||
return key.withAmount(genericStack.amount()); | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
public @Nullable GenericStack getStackFromIngredient(ChemicalStack chemicalStack) { | ||
var what = MekanismKey.of(chemicalStack); | ||
if (what == null) { | ||
return null; | ||
} | ||
return new GenericStack(what, chemicalStack.getAmount()); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/me/ramidzkh/mekae2/integration/jei/package-info.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
@ParametersAreNonnullByDefault | ||
@MethodsReturnNonnullByDefault | ||
package me.ramidzkh.mekae2.integration.jei; | ||
|
||
import net.minecraft.MethodsReturnNonnullByDefault; | ||
|
||
import javax.annotation.ParametersAreNonnullByDefault; |