From 2661e218e3a9ede8096a9f1f2dfed2ab8165595b Mon Sep 17 00:00:00 2001 From: Aaron <51387595+AzureAaron@users.noreply.github.com> Date: Sat, 20 Jul 2024 06:48:46 -0400 Subject: [PATCH] Fix Memory Leak (#853) (cherry picked from commit 6541bb6aa43a7141ac259ee34a597891d6a45689) --- .../skyblocker/skyblock/itemlist/ItemStackBuilder.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java index 6ee75161e6..e8aca5c71b 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/itemlist/ItemStackBuilder.java @@ -5,7 +5,7 @@ import io.github.moulberry.repo.constants.PetNumbers; import io.github.moulberry.repo.data.NEUItem; import io.github.moulberry.repo.data.Rarity; -import it.unimi.dsi.fastutil.ints.IntArrayList; +import it.unimi.dsi.fastutil.ints.IntList; import net.minecraft.component.DataComponentTypes; import net.minecraft.component.type.*; import net.minecraft.item.ItemStack; @@ -86,8 +86,11 @@ public static ItemStack fromNEUItem(NEUItem item) { // Add firework star color Matcher explosionColorMatcher = EXPLOSION_COLOR_PATTERN.matcher(nbttag); if (explosionColorMatcher.find()) { + //We used create an IntArrayList and took the color as the list's capacity and not add anything to the list which y'know casually leaked a lot of memory... + IntList color = IntList.of(Integer.parseInt(explosionColorMatcher.group("color"))); + //Forget about the actual ball type because it probably doesn't matter - stack.set(DataComponentTypes.FIREWORK_EXPLOSION, new FireworkExplosionComponent(FireworkExplosionComponent.Type.SMALL_BALL, new IntArrayList(Integer.parseInt(explosionColorMatcher.group("color"))), new IntArrayList(), false, false)); + stack.set(DataComponentTypes.FIREWORK_EXPLOSION, new FireworkExplosionComponent(FireworkExplosionComponent.Type.SMALL_BALL, color, IntList.of(), false, false)); } // Attach custom nbt data