From 20c515c9baed83384fbedabb6a581400a4a7c1ef Mon Sep 17 00:00:00 2001 From: NopoTheGamer <40329022+NopoTheGamer@users.noreply.github.com> Date: Sat, 11 May 2024 22:51:26 +1000 Subject: Fix local capes not updating if you didnt have a cape equiped before (#1151) --- .../notenoughupdates/cosmetics/CapeManager.java | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) 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 5ed915d0..589542d5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/cosmetics/CapeManager.java @@ -301,21 +301,19 @@ public class CapeManager { if (event.player == null) return; String uuid = event.player.getUniqueID().toString().replace("-", ""); - if (!capeMap.containsKey(uuid)) return; - + boolean isLocalPlayer = event.player == Minecraft.getMinecraft().thePlayer; boolean hasLocalCape = localCape != null && localCape.getRight() != null && !localCape.getRight().equals("null"); + if (!capeMap.containsKey(uuid) && !(hasLocalCape && isLocalPlayer)) return; try { Pair entry = capeMap.get(uuid); - String capeName = entry.getRight(); - if (capeName != null && !capeName.equals("null")) { - if (event.player == Minecraft.getMinecraft().thePlayer && hasLocalCape) { - localCape.getLeft().setCapeTexture(localCape.getValue()); - CAPE_TICKER.submit(() -> localCape.getLeft().onTick(event.player)); - } else { - entry.getLeft().setCapeTexture(capeName); - CAPE_TICKER.submit(() -> capeMap.get(uuid).getLeft().onTick(event.player)); - } + String capeName = entry == null ? null : entry.getRight(); + if (isLocalPlayer && hasLocalCape) { + localCape.getLeft().setCapeTexture(localCape.getValue()); + CAPE_TICKER.submit(() -> localCape.getLeft().onTick(event.player)); + } else if (capeName != null && !capeName.equals("null")) { + entry.getLeft().setCapeTexture(capeName); + CAPE_TICKER.submit(() -> capeMap.get(uuid).getLeft().onTick(event.player)); } else { capeMap.remove(uuid); } -- cgit