mirror of
https://github.com/GTNewHorizons/JustEnoughCalculation.git
synced 2026-11-14 01:04:06 +00:00
Fix: gtpp recipe output doubles when transfer
This commit is contained in:
1 parent
57aa9bd53f
commit
ffa8ea473f
2 files changed
+14
-8
No files matched your search
@@ -44,7 +44,6 @@ public class GTPP extends GregTech {
|
||||
Set<String> recipeNames = new HashSet<>();
|
||||
try {
|
||||
// add as many recipe as possible
|
||||
|
||||
recipeNames.addAll(
|
||||
this.reflectGetRecipeMapNEIName("gregtech.api.util.GTPP_Recipe$GTPP_Recipe_Map", "sMappings"));
|
||||
|
||||
@@ -62,7 +61,7 @@ public class GTPP extends GregTech {
|
||||
@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);
|
||||
handleDefault(recipe, index, inputs, outputs, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -66,8 +66,12 @@ public class GregTech implements IAdapter {
|
||||
}
|
||||
|
||||
protected void handleDefault(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs) {
|
||||
handleDefault(recipe, index, inputs, outputs, false);
|
||||
}
|
||||
|
||||
protected void handleDefault(IRecipeHandler recipe, int index, List<Object[]> inputs, List<Object[]> outputs, boolean clearOutput) {
|
||||
inputs.replaceAll(ts -> Arrays.stream(ts).map(o -> {
|
||||
if(o instanceof ItemStack) {
|
||||
if (o instanceof ItemStack) {
|
||||
return GregTech.convertFluid((ItemStack) o);
|
||||
} else if (o instanceof FluidStack) {
|
||||
return o;
|
||||
@@ -75,11 +79,14 @@ public class GregTech implements IAdapter {
|
||||
throw new IllegalArgumentException("Shall get ItemStack or FluidStack, but get: " + o.getClass());
|
||||
}
|
||||
}).toArray());
|
||||
if (clearOutput) {
|
||||
outputs.clear();
|
||||
}
|
||||
List<PositionedStack> otherStacks = recipe.getOtherStacks(index);
|
||||
outputs.addAll(otherStacks.stream()
|
||||
.map(positionedStack -> positionedStack.items)
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(GregTech::convertFluid).toArray())
|
||||
.collect(Collectors.toList()));
|
||||
.map(positionedStack -> positionedStack.items)
|
||||
.map(itemStacks -> Arrays.stream(itemStacks).map(GregTech::convertFluid).toArray())
|
||||
.collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public static Object convertFluid(ItemStack itemStack) {
|
||||
@@ -99,7 +106,7 @@ public class GregTech implements IAdapter {
|
||||
Method getItem = itemListClz.getMethod("getItem");
|
||||
Item displayFluidItem = (Item) getItem.invoke(display_fluid);
|
||||
if (!isStackValid(aDisplayStack) || aDisplayStack.getItem() != displayFluidItem ||
|
||||
!aDisplayStack.hasTagCompound())
|
||||
!aDisplayStack.hasTagCompound())
|
||||
return null;
|
||||
Fluid tFluid = FluidRegistry.getFluid(displayFluidItem.getDamage(aDisplayStack));
|
||||
return new FluidStack(tFluid, (int) aDisplayStack.getTagCompound().getLong("mFluidDisplayAmount"));
|
||||
@@ -111,6 +118,6 @@ public class GregTech implements IAdapter {
|
||||
|
||||
private static boolean isStackValid(Object aStack) {
|
||||
return (aStack instanceof ItemStack) && ((ItemStack) aStack).getItem() != null &&
|
||||
((ItemStack) aStack).stackSize >= 0;
|
||||
((ItemStack) aStack).stackSize >= 0;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user