diff --git a/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/DarkSteelRecipeManager.java b/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/DarkSteelRecipeManager.java index 6e0f14b8ff..353013461a 100644 --- a/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/DarkSteelRecipeManager.java +++ b/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/DarkSteelRecipeManager.java @@ -20,7 +20,6 @@ import crazypants.enderio.api.upgrades.IDarkSteelUpgrade; import crazypants.enderio.base.EnderIO; import crazypants.enderio.base.lang.Lang; -import crazypants.enderio.util.StringUtil; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.entity.player.EntityPlayer; @@ -188,6 +187,12 @@ public static void addAdvancedTooltipEntries(@Nonnull ItemStack itemstack, Entit return result.isEmpty() ? "" : NullHelper.first(result.substring(1), ""); } + public static @Nonnull NNList getUpgrades(@Nonnull ItemStack stack) { + NNList list = UpgradeRegistry.getUpgrades(); + list.removeIf(upgrade -> !upgrade.hasUpgrade(stack)); + return list; + } + public static NNList getRecipes(@Nonnull Set list, @Nonnull NNList input) { NNList output = new NNList(); NNIterator iterator = input.iterator(); @@ -222,14 +227,17 @@ public static NNList getRecipes(@Nonnull Set list, @Nonn public static class UpgradePath { private final @Nonnull ItemStack input, upgrade, output; private final @Nonnull IDarkSteelUpgrade dsupgrade; - private final @Nonnull String id; + private final int hash; UpgradePath(@Nonnull IDarkSteelUpgrade dsupgrade, @Nonnull ItemStack input, @Nonnull ItemStack upgrade, @Nonnull ItemStack output) { this.input = input; this.upgrade = upgrade; this.output = output; this.dsupgrade = dsupgrade; - this.id = StringUtil.format("%s:%s:%s", input.getItem().getRegistryName(), getUpgradesAsString(input), getUpgradesAsString(output)); + int hash = input.getItem().getRegistryName().hashCode(); + hash = hash * 31 + getUpgradesAsString(input).hashCode(); + hash = hash * 31 + getUpgradesAsString(output).hashCode(); + this.hash = hash; } public @Nonnull ItemStack getInput() { @@ -250,7 +258,7 @@ public static class UpgradePath { @Override public int hashCode() { - return id.hashCode(); + return hash; } @Override @@ -265,7 +273,13 @@ public boolean equals(Object obj) { return false; } UpgradePath other = (UpgradePath) obj; - if (!id.equals(other.id)) { + if (input.getItem() != other.getInput().getItem()) { + return false; + } + if (!getUpgrades(input).equals(getUpgrades(other.input))) { + return false; + } + if (!getUpgrades(output).equals(getUpgrades(other.output))) { return false; } return true;