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..92a5453ad2 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 @@ -6,6 +6,7 @@ import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; import javax.annotation.Nonnull; @@ -151,7 +152,11 @@ public static void addBasicTooltipEntries(@Nonnull ItemStack itemstack, EntityPl } } - public static boolean skipUpgradeTooltips = false; + public static void setSkipUpgradeTooltips(boolean skipUpgradeTooltips) { + DarkSteelRecipeManager.skipUpgradeTooltips = skipUpgradeTooltips; + } + + private static boolean skipUpgradeTooltips = false; public static void addAdvancedTooltipEntries(@Nonnull ItemStack itemstack, EntityPlayer entityplayer, @Nonnull List list, boolean flag) { SpecialTooltipHandler.addDetailedTooltipFromResources(list, itemstack.getUnlocalizedName()); @@ -179,13 +184,9 @@ public static void addAdvancedTooltipEntries(@Nonnull ItemStack itemstack, Entit } public static @Nonnull String getUpgradesAsString(@Nonnull ItemStack stack) { - String result = ""; - for (IDarkSteelUpgrade upgrade : UpgradeRegistry.getUpgrades()) { - if (upgrade.hasUpgrade(stack)) { - result += "/" + upgrade.getUnlocalizedName(); - } - } - return result.isEmpty() ? "" : NullHelper.first(result.substring(1), ""); + return NullHelper.first(UpgradeRegistry.getUpgrades().stream().filter(upgrade -> upgrade.hasUpgrade(stack)) + .map(upgrade -> "" + UpgradeRegistry.getId(upgrade)).collect(Collectors.joining("/")), ""); + // Note: Using the numeric ID here to keep the string short and save memory } public static NNList getRecipes(@Nonnull Set list, @Nonnull NNList input) { diff --git a/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/UpgradeRegistry.java b/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/UpgradeRegistry.java index adec797f9f..7dbc47af76 100644 --- a/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/UpgradeRegistry.java +++ b/enderio-base/src/main/java/crazypants/enderio/base/handler/darksteel/UpgradeRegistry.java @@ -16,6 +16,7 @@ import net.minecraftforge.fml.common.Mod.EventBusSubscriber; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.registries.ForgeRegistry; import net.minecraftforge.registries.IForgeRegistry; import net.minecraftforge.registries.IForgeRegistry.AddCallback; import net.minecraftforge.registries.IForgeRegistry.ClearCallback; @@ -59,4 +60,8 @@ public static void registerRegistry(@Nonnull RegistryEvent.NewRegistry event) { return REGISTRY.getValue(id); } + public static int getId(IDarkSteelUpgrade upgrade) { + return ((ForgeRegistry) REGISTRY).getID(upgrade); + } + } diff --git a/enderio-base/src/main/java/crazypants/enderio/base/integration/jei/DescriptionRecipeCategory.java b/enderio-base/src/main/java/crazypants/enderio/base/integration/jei/DescriptionRecipeCategory.java index da9a1d2436..0d643054e7 100644 --- a/enderio-base/src/main/java/crazypants/enderio/base/integration/jei/DescriptionRecipeCategory.java +++ b/enderio-base/src/main/java/crazypants/enderio/base/integration/jei/DescriptionRecipeCategory.java @@ -63,10 +63,10 @@ public void apply(@Nonnull Item item) { ItemStack itemStack = new ItemStack(item); NNList allTooltips; try { - DarkSteelRecipeManager.skipUpgradeTooltips = true; + DarkSteelRecipeManager.setSkipUpgradeTooltips(true); allTooltips = SpecialTooltipHandler.getAllTooltips(itemStack); } finally { - DarkSteelRecipeManager.skipUpgradeTooltips = false; + DarkSteelRecipeManager.setSkipUpgradeTooltips(false); } NNList list = DarkSteelRecipeManager.getAllRecipes(new NNList<>(itemStack));