mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-28 07:35:41 +00:00
Update bs and deps
This commit is contained in:
1 parent
19fb4c49c3
commit
296a2bdf29
108 files changed
+2886
-1739
No files matched your search
@@ -1,5 +1,13 @@
|
||||
package me.towdium.jecalculation.nei;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import codechicken.nei.api.IOverlayHandler;
|
||||
import codechicken.nei.recipe.GuiRecipeTab;
|
||||
import codechicken.nei.recipe.HandlerInfo;
|
||||
@@ -7,20 +15,16 @@ import codechicken.nei.recipe.IRecipeHandler;
|
||||
import codechicken.nei.recipe.TemplateRecipeHandler;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import javax.annotation.Nonnull;
|
||||
import me.towdium.jecalculation.data.label.ILabel;
|
||||
import me.towdium.jecalculation.data.structure.CostList;
|
||||
import me.towdium.jecalculation.data.structure.Recipe;
|
||||
import me.towdium.jecalculation.gui.JecaGui;
|
||||
import me.towdium.jecalculation.gui.guis.GuiRecipe;
|
||||
import me.towdium.jecalculation.utils.wrappers.Trio;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class JecaOverlayHandler implements IOverlayHandler {
|
||||
|
||||
@Override
|
||||
public void overlayRecipe(GuiContainer firstGui, IRecipeHandler recipe, int recipeIndex, boolean shift) {
|
||||
if (firstGui instanceof JecaGui) {
|
||||
@@ -36,8 +40,8 @@ public class JecaOverlayHandler implements IOverlayHandler {
|
||||
}
|
||||
}
|
||||
|
||||
private static EnumMap<Recipe.IO, List<Trio<ILabel, CostList, CostList>>> convertRecipe(
|
||||
IRecipeHandler recipe, int recipeIndex, Class<?> context) {
|
||||
private static EnumMap<Recipe.IO, List<Trio<ILabel, CostList, CostList>>> convertRecipe(IRecipeHandler recipe,
|
||||
int recipeIndex, Class<?> context) {
|
||||
// item disamb raw
|
||||
EnumMap<Recipe.IO, List<Trio<ILabel, CostList, CostList>>> merged = new EnumMap<>(Recipe.IO.class);
|
||||
|
||||
@@ -51,47 +55,52 @@ public class JecaOverlayHandler implements IOverlayHandler {
|
||||
// output
|
||||
recipeOutputs.forEach(o -> merge(merged, Arrays.asList(o), context, Recipe.IO.OUTPUT));
|
||||
|
||||
JecaOverlayHandler.getCatalyst(recipe).ifPresent(catalyst -> {
|
||||
List<ItemStack> catalysts = Collections.singletonList(catalyst);
|
||||
merge(merged, catalysts, context, Recipe.IO.CATALYST);
|
||||
});
|
||||
JecaOverlayHandler.getCatalyst(recipe)
|
||||
.ifPresent(catalyst -> {
|
||||
List<ItemStack> catalysts = Collections.singletonList(catalyst);
|
||||
merge(merged, catalysts, context, Recipe.IO.CATALYST);
|
||||
});
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static void merge(
|
||||
EnumMap<Recipe.IO, List<Trio<ILabel, CostList, CostList>>> dst,
|
||||
List<?> objs,
|
||||
Class<?> context,
|
||||
Recipe.IO type) {
|
||||
List<ILabel> list = objs.stream().map(ILabel.Converter::from).collect(Collectors.toList());
|
||||
private static void merge(EnumMap<Recipe.IO, List<Trio<ILabel, CostList, CostList>>> dst, List<?> objs,
|
||||
Class<?> context, Recipe.IO type) {
|
||||
List<ILabel> list = objs.stream()
|
||||
.map(ILabel.Converter::from)
|
||||
.collect(Collectors.toList());
|
||||
if (list.isEmpty()) return;
|
||||
ILabel rep = list.get(0).copy();
|
||||
ILabel rep = list.get(0)
|
||||
.copy();
|
||||
if (type == Recipe.IO.INPUT && list.size() != 1) rep = ILabel.CONVERTER.first(list, context);
|
||||
ILabel fin = rep;
|
||||
|
||||
dst.computeIfAbsent(type, i -> new ArrayList<>()).stream()
|
||||
.filter(p -> {
|
||||
CostList cl = new CostList(list);
|
||||
if (p.three.equals(cl)) {
|
||||
ILabel.MERGER.merge(p.one, fin).ifPresent(i -> p.one = i);
|
||||
p.two = CostList.merge(p.two, cl, true);
|
||||
return true;
|
||||
} else return false;
|
||||
})
|
||||
.findAny()
|
||||
.orElseGet(() -> {
|
||||
Trio<ILabel, CostList, CostList> ret = new Trio<>(fin, new CostList(list), new CostList(list));
|
||||
dst.get(type).add(ret);
|
||||
return ret;
|
||||
});
|
||||
dst.computeIfAbsent(type, i -> new ArrayList<>())
|
||||
.stream()
|
||||
.filter(p -> {
|
||||
CostList cl = new CostList(list);
|
||||
if (p.three.equals(cl)) {
|
||||
ILabel.MERGER.merge(p.one, fin)
|
||||
.ifPresent(i -> p.one = i);
|
||||
p.two = CostList.merge(p.two, cl, true);
|
||||
return true;
|
||||
} else return false;
|
||||
})
|
||||
.findAny()
|
||||
.orElseGet(() -> {
|
||||
Trio<ILabel, CostList, CostList> ret = new Trio<>(fin, new CostList(list), new CostList(list));
|
||||
dst.get(type)
|
||||
.add(ret);
|
||||
return ret;
|
||||
});
|
||||
}
|
||||
|
||||
private static Optional<ItemStack> getCatalyst(@Nonnull IRecipeHandler handler) {
|
||||
if (!NEIPlugin.isCatalystEnabled()) {
|
||||
return Optional.empty();
|
||||
}
|
||||
final String handlerName = handler.toString().split("@")[0];
|
||||
final String handlerName = handler.toString()
|
||||
.split("@")[0];
|
||||
final String handlerID;
|
||||
if (handler instanceof TemplateRecipeHandler) {
|
||||
handlerID = (((TemplateRecipeHandler) handler).getOverlayIdentifier());
|
||||
|
||||
Reference in new issue
Block a user