-
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.
- Loading branch information
Showing
4 changed files
with
57 additions
and
54 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
37 changes: 19 additions & 18 deletions
37
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 |
---|---|---|
@@ -1,30 +1,31 @@ | ||
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; | ||
|
||
import me.ramidzkh.mekae2.AppliedMekanistics; | ||
import mezz.jei.api.IModPlugin; | ||
import mezz.jei.api.JeiPlugin; | ||
|
||
@JeiPlugin | ||
public class AMJeiPlugin implements IModPlugin { | ||
@Override | ||
public ResourceLocation getPluginUid() { | ||
return ResourceLocation.fromNamespaceAndPath(AppliedMekanistics.ID, "jei_plugin"); | ||
} | ||
@Override | ||
public ResourceLocation getPluginUid() { | ||
return ResourceLocation.fromNamespaceAndPath(AppliedMekanistics.ID, "jei_plugin"); | ||
} | ||
|
||
public AMJeiPlugin() { | ||
if (isModLoaded("ae2jeiintegration")) { | ||
AE2JeiIntegrationHelper.register(); | ||
} | ||
} | ||
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); | ||
} | ||
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); | ||
} | ||
} |
64 changes: 33 additions & 31 deletions
64
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 |
---|---|---|
@@ -1,43 +1,45 @@ | ||
package me.ramidzkh.mekae2.integration.jei; | ||
|
||
import appeng.api.stacks.GenericStack; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
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; | ||
|
||
import appeng.api.stacks.GenericStack; | ||
|
||
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()); | ||
} | ||
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()); | ||
} | ||
} |
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