Files
ModTweaker/src/main/java/modtweaker2/mods/appeng/AppliedEnergisticsHelper.java
T

79 lines
2.0 KiB
Java
Raw Normal View History

2015-06-29 16:36:35 +02:00
package modtweaker2.mods.appeng;
import static modtweaker2.helpers.StackHelper.areEqualOrNull;
2015-06-29 16:36:35 +02:00
import net.minecraft.item.ItemStack;
2015-06-29 16:36:35 +02:00
import appeng.api.features.IGrinderEntry;
import appeng.api.features.IInscriberRecipe;
public class AppliedEnergisticsHelper {
2015-06-29 16:36:35 +02:00
/**
* Compares two IInscriberRecipe objects, if they are the same or have the same inputs
*/
public static boolean equals(IInscriberRecipe r1, IInscriberRecipe r2) {
if (r1 == r2) {
2015-06-29 16:36:35 +02:00
return true;
}
2015-06-29 16:36:35 +02:00
if (r1 == null || r2 == null) {
return false;
}
if (!areEqualOrNull(r1.getTopOptional().orNull(), r2.getTopOptional().orNull())) {
return false;
2015-06-29 16:36:35 +02:00
}
if (!areEqualOrNull(r1.getBottomOptional().orNull(), r2.getBottomOptional().orNull())) {
return false;
2015-06-29 16:36:35 +02:00
}
if (r1.getInputs() == null && r2.getInputs() != null || r1.getInputs() != null && r2.getInputs() == null) {
2015-06-29 16:36:35 +02:00
return false;
}
if (r1.getInputs() != null && r2.getInputs() != null) {
if (r1.getInputs().size() != r2.getInputs().size()) {
2015-06-29 16:36:35 +02:00
return false;
}
2015-06-29 16:36:35 +02:00
// Check if every item in recipe 1 is in recipe 2
for (ItemStack i1 : r1.getInputs()) {
2015-06-29 16:36:35 +02:00
boolean found = false;
for (ItemStack i2 : r2.getInputs()) {
if (areEqualOrNull(i1, i2)) {
2015-06-29 16:36:35 +02:00
found = true;
}
}
if (!found) {
2015-06-29 16:36:35 +02:00
return false;
}
}
}
2015-06-29 16:36:35 +02:00
return true;
}
2015-06-29 16:36:35 +02:00
/**
* Compares two IGrinderEntry objects, if they are the same or have the same inputs
*/
public static boolean equals(IGrinderEntry r1, IGrinderEntry r2) {
if (r1 == r2) {
2015-06-29 16:36:35 +02:00
return true;
}
2015-06-29 16:36:35 +02:00
if (r1 == null || r2 == null) {
return false;
}
if (!areEqualOrNull(r1.getInput(), r2.getInput())) {
2015-06-29 16:36:35 +02:00
return false;
}
return true;
}
}