strip some tags that hold data that isn't relevant
This commit is contained in:
@@ -32,7 +32,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
public CraftingPattern(World world, ICraftingPatternContainer container, ItemStack stack) {
|
||||
this.container = container;
|
||||
this.stack = stack;
|
||||
this.stack = stripTags(stack);
|
||||
|
||||
InventoryCrafting inv = new InventoryCrafting(new Container() {
|
||||
@Override
|
||||
@@ -44,7 +44,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
for (int i = 0; i < 9; ++i) {
|
||||
ItemStack slot = ItemPattern.getSlot(stack, i);
|
||||
|
||||
inputs.add(slot);
|
||||
inputs.add(stripTags(slot));
|
||||
|
||||
if (slot != null) {
|
||||
inv.setInventorySlotContents(i, slot);
|
||||
@@ -60,10 +60,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
// It is a dirty fix, but hey someone has to do it. ~ way2muchnoise 2016 "bite me"
|
||||
mekanism = recipe.getClass().getName().equals("mekanism.common.recipe.ShapedMekanismRecipe");
|
||||
|
||||
ItemStack out = output.copy();
|
||||
if (mekanism && out.hasTagCompound()) {
|
||||
out.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
ItemStack out = stripTags(output.copy());
|
||||
outputs.add(out);
|
||||
|
||||
if ((isOredict() && shapedOre) || mekanism) {
|
||||
@@ -81,10 +78,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
if (input == null) {
|
||||
oreInputs.add(Collections.emptyList());
|
||||
} else if (input instanceof ItemStack) {
|
||||
ItemStack stripped = ((ItemStack) input).copy();
|
||||
if (mekanism && ((ItemStack) input).hasTagCompound()) {
|
||||
stripped.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
ItemStack stripped = stripTags(((ItemStack) input).copy());
|
||||
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
stripped.setItemDamage(0);
|
||||
}
|
||||
@@ -92,10 +86,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
} else {
|
||||
List<ItemStack> cleaned = new LinkedList<>();
|
||||
for (ItemStack in : (List<ItemStack>) input) {
|
||||
ItemStack stripped = in.copy();
|
||||
if (mekanism && stripped.hasTagCompound()) {
|
||||
stripped.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
ItemStack stripped = stripTags(in.copy());
|
||||
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||
stripped.setItemDamage(0);
|
||||
}
|
||||
@@ -108,17 +99,14 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
||||
if (remaining != null) {
|
||||
ItemStack cleaned = remaining.copy();
|
||||
if (mekanism && cleaned.hasTagCompound()) {
|
||||
cleaned.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
ItemStack cleaned = stripTags(remaining.copy());
|
||||
byproducts.add(cleaned);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
outputs = ItemPattern.getOutputs(stack);
|
||||
outputs = ItemPattern.getOutputs(stack).stream().map(CraftingPattern::stripTags).collect(Collectors.toList());
|
||||
|
||||
if (isOredict()) {
|
||||
for (ItemStack input : inputs) {
|
||||
@@ -128,13 +116,14 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
} else {
|
||||
int[] ids = OreDictionary.getOreIDs(input);
|
||||
if (ids == null || ids.length == 0) {
|
||||
oreInputs.add(Collections.singletonList(input));
|
||||
oreInputs.add(Collections.singletonList(stripTags(input)));
|
||||
} else {
|
||||
oreInputs.add(Arrays.stream(ids)
|
||||
.mapToObj(OreDictionary::getOreName)
|
||||
.map(OreDictionary::getOres)
|
||||
.flatMap(List::stream)
|
||||
.map(ItemStack::copy)
|
||||
.map(CraftingPattern::stripTags)
|
||||
.map(s -> {
|
||||
s.setCount(input.getCount());
|
||||
return s;
|
||||
@@ -152,7 +141,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
if (input == null) {
|
||||
oreInputs.add(Collections.emptyList());
|
||||
} else {
|
||||
oreInputs.add(Collections.singletonList(input));
|
||||
oreInputs.add(Collections.singletonList(stripTags(input)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -215,11 +204,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
if (cleaned.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
cleaned = cleaned.copy();
|
||||
if (mekanism && cleaned.hasTagCompound()) {
|
||||
cleaned.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
outputs.add(cleaned);
|
||||
outputs.add(stripTags(cleaned.copy()));
|
||||
|
||||
return outputs;
|
||||
}
|
||||
@@ -248,11 +233,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
||||
if (remaining != null) {
|
||||
ItemStack cleaned = remaining.copy();
|
||||
if (mekanism && cleaned.hasTagCompound()) {
|
||||
cleaned.getTagCompound().removeTag("mekData");
|
||||
}
|
||||
byproducts.add(cleaned);
|
||||
byproducts.add(stripTags(remaining.copy()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -272,7 +253,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
@Override
|
||||
public int getQuantityPerRequest(ItemStack requested, int compare) {
|
||||
int quantity = 0;
|
||||
|
||||
requested = stripTags(requested);
|
||||
for (ItemStack output : outputs) {
|
||||
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
||||
quantity += output.getCount();
|
||||
@@ -288,6 +269,7 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
|
||||
@Override
|
||||
public ItemStack getActualOutput(ItemStack requested, int compare) {
|
||||
requested = stripTags(requested);
|
||||
for (ItemStack output : outputs) {
|
||||
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
||||
return output.copy();
|
||||
@@ -306,4 +288,20 @@ public class CraftingPattern implements ICraftingPattern {
|
||||
", byproducts=" + byproducts +
|
||||
'}';
|
||||
}
|
||||
|
||||
private static ItemStack stripTags(ItemStack stack) {
|
||||
if (stack.hasTagCompound()) {
|
||||
switch (stack.getItem().getRegistryName().getResourceDomain()) {
|
||||
case "mekanism":
|
||||
stack.getTagCompound().removeTag("mekData");
|
||||
break;
|
||||
case "enderio":
|
||||
stack.getTagCompound().removeTag("entity");
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user