mirror of
https://github.com/GTNewHorizons/AE2FluidCraft-Rework.git
synced 2026-11-15 17:44:46 +00:00
Merge branch 'master' into upstream
This commit is contained in:
27 files changed
+670
-355
No files matched your search
@@ -11,6 +11,7 @@ import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.util.Constants;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
@@ -87,7 +88,9 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
if (condensed.length == 0) {
|
||||
return false;
|
||||
}
|
||||
this.outputs = outputs;
|
||||
this.outputs = Arrays.stream(outputs)
|
||||
.filter(Objects::nonNull)
|
||||
.toArray(IAEItemStack[]::new);
|
||||
this.outputsCond = condensed;
|
||||
return true;
|
||||
}
|
||||
@@ -159,12 +162,11 @@ public class FluidPatternDetails implements ICraftingPatternDetails, Comparable<
|
||||
public static NBTTagList writeStackArray(IAEItemStack[] stacks) {
|
||||
NBTTagList listTag = new NBTTagList();
|
||||
for (IAEItemStack stack : stacks) {
|
||||
if (stack != null) {
|
||||
// see note at top of class
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
stack.writeToNBT(stackTag);
|
||||
listTag.appendTag(stackTag);
|
||||
}
|
||||
// see note at top of class
|
||||
NBTTagCompound stackTag = new NBTTagCompound();
|
||||
if (stack != null) stack.writeToNBT(stackTag);
|
||||
|
||||
listTag.appendTag(stackTag);
|
||||
}
|
||||
return listTag;
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ public final class ModAndClassUtil {
|
||||
public static boolean EIO = false;
|
||||
public static boolean FTR = false;
|
||||
public static boolean OC = false;
|
||||
public static boolean GTPP = false;
|
||||
|
||||
public static boolean isDoubleButton;
|
||||
public static boolean isSaveText;
|
||||
@@ -98,8 +99,7 @@ public final class ModAndClassUtil {
|
||||
FTR = true;
|
||||
if (Loader.isModLoaded("OpenComputers"))
|
||||
OC = true;
|
||||
if (Loader.isModLoaded("miscutils"))
|
||||
GTPP = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package com.glodblock.github.util;
|
||||
|
||||
import codechicken.nei.PositionedStack;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class NEIUtil {
|
||||
|
||||
public static List<PositionedStack> compress(List<PositionedStack> list) {
|
||||
List<PositionedStack> comp = new LinkedList<>();
|
||||
for (PositionedStack positionedStack : list) {
|
||||
if (positionedStack == null) continue;
|
||||
ItemStack currentStack = positionedStack.items[0].copy();
|
||||
if (currentStack.stackSize == 0) continue;
|
||||
boolean find = false;
|
||||
for (PositionedStack storedStack : comp) {
|
||||
if (storedStack == null) continue;
|
||||
ItemStack firstStack = storedStack.items[0].copy();
|
||||
boolean areItemStackEqual = firstStack.isItemEqual(currentStack) && ItemStack.areItemStackTagsEqual(firstStack, currentStack);
|
||||
if (areItemStackEqual && (firstStack.stackSize + currentStack.stackSize) <= firstStack.getMaxStackSize()) {
|
||||
find = true;
|
||||
storedStack.items[0].stackSize = firstStack.stackSize + currentStack.stackSize;
|
||||
}
|
||||
}
|
||||
if (!find) {
|
||||
comp.add(positionedStack.copy());
|
||||
}
|
||||
}
|
||||
return comp.stream().filter(Objects::nonNull).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user