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) {
|
public CraftingPattern(World world, ICraftingPatternContainer container, ItemStack stack) {
|
||||||
this.container = container;
|
this.container = container;
|
||||||
this.stack = stack;
|
this.stack = stripTags(stack);
|
||||||
|
|
||||||
InventoryCrafting inv = new InventoryCrafting(new Container() {
|
InventoryCrafting inv = new InventoryCrafting(new Container() {
|
||||||
@Override
|
@Override
|
||||||
@@ -44,7 +44,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
for (int i = 0; i < 9; ++i) {
|
for (int i = 0; i < 9; ++i) {
|
||||||
ItemStack slot = ItemPattern.getSlot(stack, i);
|
ItemStack slot = ItemPattern.getSlot(stack, i);
|
||||||
|
|
||||||
inputs.add(slot);
|
inputs.add(stripTags(slot));
|
||||||
|
|
||||||
if (slot != null) {
|
if (slot != null) {
|
||||||
inv.setInventorySlotContents(i, slot);
|
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"
|
// 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");
|
mekanism = recipe.getClass().getName().equals("mekanism.common.recipe.ShapedMekanismRecipe");
|
||||||
|
|
||||||
ItemStack out = output.copy();
|
ItemStack out = stripTags(output.copy());
|
||||||
if (mekanism && out.hasTagCompound()) {
|
|
||||||
out.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
outputs.add(out);
|
outputs.add(out);
|
||||||
|
|
||||||
if ((isOredict() && shapedOre) || mekanism) {
|
if ((isOredict() && shapedOre) || mekanism) {
|
||||||
@@ -81,10 +78,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
if (input == null) {
|
if (input == null) {
|
||||||
oreInputs.add(Collections.emptyList());
|
oreInputs.add(Collections.emptyList());
|
||||||
} else if (input instanceof ItemStack) {
|
} else if (input instanceof ItemStack) {
|
||||||
ItemStack stripped = ((ItemStack) input).copy();
|
ItemStack stripped = stripTags(((ItemStack) input).copy());
|
||||||
if (mekanism && ((ItemStack) input).hasTagCompound()) {
|
|
||||||
stripped.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||||
stripped.setItemDamage(0);
|
stripped.setItemDamage(0);
|
||||||
}
|
}
|
||||||
@@ -92,10 +86,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
} else {
|
} else {
|
||||||
List<ItemStack> cleaned = new LinkedList<>();
|
List<ItemStack> cleaned = new LinkedList<>();
|
||||||
for (ItemStack in : (List<ItemStack>) input) {
|
for (ItemStack in : (List<ItemStack>) input) {
|
||||||
ItemStack stripped = in.copy();
|
ItemStack stripped = stripTags(in.copy());
|
||||||
if (mekanism && stripped.hasTagCompound()) {
|
|
||||||
stripped.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
if (stripped.getItemDamage() == OreDictionary.WILDCARD_VALUE) {
|
||||||
stripped.setItemDamage(0);
|
stripped.setItemDamage(0);
|
||||||
}
|
}
|
||||||
@@ -108,17 +99,14 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
||||||
if (remaining != null) {
|
if (remaining != null) {
|
||||||
ItemStack cleaned = remaining.copy();
|
ItemStack cleaned = stripTags(remaining.copy());
|
||||||
if (mekanism && cleaned.hasTagCompound()) {
|
|
||||||
cleaned.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
byproducts.add(cleaned);
|
byproducts.add(cleaned);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
outputs = ItemPattern.getOutputs(stack);
|
outputs = ItemPattern.getOutputs(stack).stream().map(CraftingPattern::stripTags).collect(Collectors.toList());
|
||||||
|
|
||||||
if (isOredict()) {
|
if (isOredict()) {
|
||||||
for (ItemStack input : inputs) {
|
for (ItemStack input : inputs) {
|
||||||
@@ -128,13 +116,14 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
} else {
|
} else {
|
||||||
int[] ids = OreDictionary.getOreIDs(input);
|
int[] ids = OreDictionary.getOreIDs(input);
|
||||||
if (ids == null || ids.length == 0) {
|
if (ids == null || ids.length == 0) {
|
||||||
oreInputs.add(Collections.singletonList(input));
|
oreInputs.add(Collections.singletonList(stripTags(input)));
|
||||||
} else {
|
} else {
|
||||||
oreInputs.add(Arrays.stream(ids)
|
oreInputs.add(Arrays.stream(ids)
|
||||||
.mapToObj(OreDictionary::getOreName)
|
.mapToObj(OreDictionary::getOreName)
|
||||||
.map(OreDictionary::getOres)
|
.map(OreDictionary::getOres)
|
||||||
.flatMap(List::stream)
|
.flatMap(List::stream)
|
||||||
.map(ItemStack::copy)
|
.map(ItemStack::copy)
|
||||||
|
.map(CraftingPattern::stripTags)
|
||||||
.map(s -> {
|
.map(s -> {
|
||||||
s.setCount(input.getCount());
|
s.setCount(input.getCount());
|
||||||
return s;
|
return s;
|
||||||
@@ -152,7 +141,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
if (input == null) {
|
if (input == null) {
|
||||||
oreInputs.add(Collections.emptyList());
|
oreInputs.add(Collections.emptyList());
|
||||||
} else {
|
} else {
|
||||||
oreInputs.add(Collections.singletonList(input));
|
oreInputs.add(Collections.singletonList(stripTags(input)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,11 +204,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
if (cleaned.isEmpty()) {
|
if (cleaned.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
cleaned = cleaned.copy();
|
outputs.add(stripTags(cleaned.copy()));
|
||||||
if (mekanism && cleaned.hasTagCompound()) {
|
|
||||||
cleaned.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
outputs.add(cleaned);
|
|
||||||
|
|
||||||
return outputs;
|
return outputs;
|
||||||
}
|
}
|
||||||
@@ -248,11 +233,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
for (ItemStack remaining : recipe.getRemainingItems(inv)) {
|
||||||
if (remaining != null) {
|
if (remaining != null) {
|
||||||
ItemStack cleaned = remaining.copy();
|
byproducts.add(stripTags(remaining.copy()));
|
||||||
if (mekanism && cleaned.hasTagCompound()) {
|
|
||||||
cleaned.getTagCompound().removeTag("mekData");
|
|
||||||
}
|
|
||||||
byproducts.add(cleaned);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,7 +253,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
@Override
|
@Override
|
||||||
public int getQuantityPerRequest(ItemStack requested, int compare) {
|
public int getQuantityPerRequest(ItemStack requested, int compare) {
|
||||||
int quantity = 0;
|
int quantity = 0;
|
||||||
|
requested = stripTags(requested);
|
||||||
for (ItemStack output : outputs) {
|
for (ItemStack output : outputs) {
|
||||||
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
||||||
quantity += output.getCount();
|
quantity += output.getCount();
|
||||||
@@ -288,6 +269,7 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getActualOutput(ItemStack requested, int compare) {
|
public ItemStack getActualOutput(ItemStack requested, int compare) {
|
||||||
|
requested = stripTags(requested);
|
||||||
for (ItemStack output : outputs) {
|
for (ItemStack output : outputs) {
|
||||||
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
if (API.instance().getComparer().isEqual(requested, output, compare)) {
|
||||||
return output.copy();
|
return output.copy();
|
||||||
@@ -306,4 +288,20 @@ public class CraftingPattern implements ICraftingPattern {
|
|||||||
", byproducts=" + byproducts +
|
", 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