Skip to content

Commit

Permalink
spotless apply
Browse files Browse the repository at this point in the history
  • Loading branch information
mezz committed Aug 26, 2024
1 parent 6a540f5 commit 15cd8ba
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import tamaized.ae2jeiintegration.api.integrations.jei.IngredientConverters;

public class AE2JeiIntegrationHelper {
public static void register() {
IngredientConverters.register(new ChemicalIngredientConverter());
}
public static void register() {
IngredientConverters.register(new ChemicalIngredientConverter());
}
}
37 changes: 19 additions & 18 deletions src/main/java/me/ramidzkh/mekae2/integration/jei/AMJeiPlugin.java
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);
}
}
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());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
@MethodsReturnNonnullByDefault
package me.ramidzkh.mekae2.integration.jei;

import net.minecraft.MethodsReturnNonnullByDefault;

import javax.annotation.ParametersAreNonnullByDefault;

import net.minecraft.MethodsReturnNonnullByDefault;

0 comments on commit 15cd8ba

Please sign in to comment.