Skip to content

Commit

Permalink
Fix Memory Leak (#853)
Browse files Browse the repository at this point in the history
(cherry picked from commit 6541bb6)
  • Loading branch information
AzureAaron authored and kevinthegreat1 committed Jul 26, 2024
1 parent 921e16a commit 2661e21
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 2661e21

Please sign in to comment.