From 8b7c200770f12503df891a1443c5496f9d5f7452 Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Tue, 23 Apr 2024 16:06:04 +1000 Subject: Fix capes going crazy when the plater leaves render distance (#1108) Fixed capes going crazy when the player unloads --- .../notenoughupdates/cosmetics/CapeManager.java | 16 ++++++++++++++++ .../moulberry/notenoughupdates/cosmetics/NEUCape.java | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java index 984a7931..a544ba1d 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -26,11 +26,14 @@ import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; import net.minecraft.client.Minecraft; +import net.minecraft.client.entity.EntityOtherPlayerMP; import net.minecraft.client.renderer.OpenGlHelper; import net.minecraft.client.shader.Framebuffer; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.potion.Potion; import net.minecraftforge.client.event.RenderPlayerEvent; +import net.minecraftforge.event.entity.EntityJoinWorldEvent; import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; @@ -385,4 +388,17 @@ public class CapeManager { public CapeData[] getCapes() { return capes; } + + @SubscribeEvent + public void onEntityJoinWorldEvent(EntityJoinWorldEvent event) { + if (!(event.entity instanceof EntityOtherPlayerMP)) return; + EntityOtherPlayerMP player = (EntityOtherPlayerMP) event.entity; + Pair neuCapeStringPair = capeMap.get(player.getGameProfile().getId().toString()); + if (neuCapeStringPair == null) return; + if (neuCapeStringPair.getLeft() == null) { + return; + } + neuCapeStringPair.getLeft().resetNodes(); + + } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java index d32abf64..12cbbdfd 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/NEUCape.java @@ -580,6 +580,10 @@ public class NEUCape { return x * m + b; } + public void resetNodes() { + nodes = null; + } + private void updateCape(EntityPlayer player) { Vector3f capeTranslation = updateFixedCapeNodes(player); -- cgit