mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-22 04:52:29 +00:00
feat: add Avaritia support
This commit is contained in:
1 parent
0b5e590013
commit
815af30b79
14 files changed
+109
-23
No files matched your search
@@ -1,6 +1,5 @@
|
||||
package me.towdium.jecalculation;
|
||||
|
||||
import codechicken.core.CommonUtils;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.common.config.Configuration;
|
||||
@@ -15,6 +14,7 @@ public class JecaConfig {
|
||||
public static final File defaultFile = new File(configDir, "default.json");
|
||||
|
||||
public static final File dataDir = new File(configDir, "data/");
|
||||
|
||||
public static File getDataFile(String group) {
|
||||
return new File(dataDir, group + ".json");
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package me.towdium.jecalculation.event.handlers;
|
||||
import codechicken.nei.NEIClientConfig;
|
||||
import codechicken.nei.NEIClientUtils;
|
||||
import codechicken.nei.guihook.IContainerInputHandler;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import me.towdium.jecalculation.data.label.ILabel;
|
||||
import me.towdium.jecalculation.gui.JecaGui;
|
||||
import me.towdium.jecalculation.nei.NEIPlugin;
|
||||
|
||||
@@ -4,10 +4,7 @@ import codechicken.nei.PositionedStack;
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import me.towdium.jecalculation.nei.adapter.AE2;
|
||||
import me.towdium.jecalculation.nei.adapter.Forestry;
|
||||
import me.towdium.jecalculation.nei.adapter.GregTech;
|
||||
import me.towdium.jecalculation.nei.adapter.IAdapter;
|
||||
import me.towdium.jecalculation.nei.adapter.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -21,13 +18,21 @@ public class Adapter {
|
||||
adapters.add(new Forestry());
|
||||
}
|
||||
if (Loader.isModLoaded("appliedenergistics2")) {
|
||||
JustEnoughCalculation.logger.info("ae2 installed");
|
||||
JustEnoughCalculation.logger.info("ae2 not supported");
|
||||
adapters.add(new AE2());
|
||||
}
|
||||
if (Loader.isModLoaded("gregtech")) {
|
||||
JustEnoughCalculation.logger.info("gregtech installed");
|
||||
adapters.add(new GregTech());
|
||||
}
|
||||
if (Loader.isModLoaded("miscutils")) {
|
||||
JustEnoughCalculation.logger.info("gt++ not supported");
|
||||
adapters.add(new GTPP());
|
||||
}
|
||||
if (Loader.isModLoaded("Avaritia")) {
|
||||
JustEnoughCalculation.logger.info("Avaritia installed");
|
||||
adapters.add(new Avaritia());
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
package me.towdium.jecalculation.nei;
|
||||
|
||||
import codechicken.nei.guihook.GuiContainerManager;
|
||||
import codechicken.nei.recipe.*;
|
||||
import codechicken.nei.recipe.GuiCraftingRecipe;
|
||||
import codechicken.nei.recipe.GuiUsageRecipe;
|
||||
import cpw.mods.fml.common.Loader;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
import me.towdium.jecalculation.data.label.ILabel;
|
||||
|
||||
@@ -2,11 +2,13 @@ package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public class AE2 implements IAdapter{
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
|
||||
@@ -1,10 +1,6 @@
|
||||
package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@ParametersAreNonnullByDefault
|
||||
public class Avaritia implements IAdapter {
|
||||
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
return new HashSet<>(Arrays.asList("extreme_compression", "extreme"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package me.towdium.jecalculation.nei.adapter;
|
||||
|
||||
import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import gregtech.api.util.GTPP_Recipe;
|
||||
import gtPlusPlus.nei.*;
|
||||
import me.towdium.jecalculation.JustEnoughCalculation;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
|
||||
/**
|
||||
* don't work, why?
|
||||
*/
|
||||
@ParametersAreNonnullByDefault
|
||||
public class GTPP extends GregTech {
|
||||
|
||||
private final static Set<Class<? extends TemplateRecipeHandler>> defaultHandlers = Stream.of(
|
||||
GTPP_NEI_DefaultHandler.class, GT_NEI_VacFurnace.class, GT_NEI_RFPP.class,
|
||||
GT_NEI_multiCentriElectroFreezer.class, GT_NEI_MillingMachine.class, GT_NEI_FluidReactor.class,
|
||||
GT_NEI_FlotationCell.class, DecayableRecipeHandler.class).collect(Collectors.toSet());
|
||||
|
||||
@Override
|
||||
public Set<String> getAllOverlayIdentifier() {
|
||||
Set<String> recipeNames = GTPP_Recipe.GT_Recipe_Map.sMappings.stream()
|
||||
.map(gt_recipe_map -> gt_recipe_map.mNEIName)
|
||||
.collect(Collectors.toSet());
|
||||
recipeNames.add("GTPP_Decayables");
|
||||
JustEnoughCalculation.logger.info("GTPP recipe handlers cecipe name");
|
||||
for (String recipeName : recipeNames) {
|
||||
JustEnoughCalculation.logger.info(" " + recipeName);
|
||||
}
|
||||
return recipeNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
if (defaultHandlers.stream().anyMatch(aClass -> aClass.isInstance(recipe))) {
|
||||
handleDefault(recipe, index, inputs, outputs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -28,19 +28,23 @@ public class GregTech implements IAdapter {
|
||||
@Override
|
||||
public void handleRecipe(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
if (recipe instanceof GT_NEI_DefaultHandler || recipe instanceof GT_NEI_AssLineHandler) {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
Object[] objects = Arrays.stream(inputs.get(i)).map(o -> this.convertFluid((ItemStack) o)).toArray();
|
||||
inputs.set(i, objects);
|
||||
}
|
||||
List<PositionedStack> otherStacks = recipe.getOtherStacks(index);
|
||||
outputs.addAll(otherStacks.stream()
|
||||
.map(positionedStack -> positionedStack.items)
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(this::convertFluid).toArray())
|
||||
.collect(Collectors.toList()));
|
||||
handleDefault(recipe, index, inputs, outputs);
|
||||
}
|
||||
}
|
||||
|
||||
private Object convertFluid(ItemStack itemStack) {
|
||||
protected void handleDefault(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
for (int i = 0; i < inputs.size(); i++) {
|
||||
Object[] objects = Arrays.stream(inputs.get(i)).map(o -> this.convertFluid((ItemStack) o)).toArray();
|
||||
inputs.set(i, objects);
|
||||
}
|
||||
List<PositionedStack> otherStacks = recipe.getOtherStacks(index);
|
||||
outputs.addAll(otherStacks.stream()
|
||||
.map(positionedStack -> positionedStack.items)
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(this::convertFluid).toArray())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
protected Object convertFluid(ItemStack itemStack) {
|
||||
FluidStack fluidStack = GT_Utility.getFluidFromDisplayStack(itemStack);
|
||||
return fluidStack == null ? itemStack : fluidStack;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user