From ac5af485fdb9f775ba1a5466094e3a988c9ae98b Mon Sep 17 00:00:00 2001 From: Pelotrio <45769595+Pelotrio@users.noreply.github.com> Date: Fri, 10 Nov 2023 01:03:27 +0100 Subject: [PATCH] Make randomEntity a local field to prevent leaking the world also minor refactor --- .../client/render/item/RenderMobSoul.java | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java index 0a7f2b97e..b22f3e229 100644 --- a/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java +++ b/src/main/java/com/brandon3055/draconicevolution/client/render/item/RenderMobSoul.java @@ -15,11 +15,10 @@ public class RenderMobSoul implements IItemRenderer { - private Minecraft mc; - private Entity randomEntity = null; - private String[] randomEntitys = new String[] { "Pig", "Sheep", "Enderman", "Zombie", "Creeper", "Cow", "Chicken", - "Ozelot", "Witch", "Wolf", "MushroomCow", "Squid", "EntityHorse", "Spider", "Skeleton", "Blaze", "Bat", - "Villager", "Silverfish" }; + private final Minecraft mc; + private final String[] randomEntities = new String[] { "Pig", "Sheep", "Enderman", "Zombie", "Creeper", "Cow", + "Chicken", "Ozelot", "Witch", "Wolf", "MushroomCow", "Squid", "EntityHorse", "Spider", "Skeleton", "Blaze", + "Bat", "Villager", "Silverfish" }; public RenderMobSoul() { this.mc = Minecraft.getMinecraft(); @@ -40,8 +39,8 @@ public boolean shouldUseRenderHelper(ItemRenderType type, ItemStack item, ItemRe @Override public void renderItem(ItemRenderType type, ItemStack item, Object... data) { Entity mob = EntityList.createEntityByName(ItemNBTHelper.getString(item, "Name", "Pig"), mc.theWorld); - randomEntity = EntityList - .createEntityByName(randomEntitys[(int) ((Minecraft.getSystemTime() / 1000) % 18)], mc.theWorld); + Entity randomEntity = EntityList + .createEntityByName(randomEntities[(int) ((Minecraft.getSystemTime() / 1000) % 18)], mc.theWorld); if (ItemNBTHelper.getString(item, "Name", "Pig").equals("Any")) mob = randomEntity; if (mob instanceof EntitySkeleton) ((EntitySkeleton) mob).setSkeletonType(ItemNBTHelper.getInteger(item, "SkeletonType", 0));