From a6ad2c19aa95f53a942a1727c757ec469ed80c56 Mon Sep 17 00:00:00 2001 From: Logan <37521985+LoJoSho@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:49:41 -0600 Subject: [PATCH] fix: fix client crashes for wardrobe on 1.21.10 --- build.gradle.kts | 2 +- .../util/packets/HMCCPacketManager.java | 37 ++++--------------- 2 files changed, 9 insertions(+), 30 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 17e5193f..5f76ab8f 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -92,7 +92,7 @@ allprojects { compileOnly("io.github.toxicity188:BetterCommand:1.3") //BetterCommand library //compileOnly("it.unimi.dsi:fastutil:8.5.14") compileOnly("org.projectlombok:lombok:1.18.34") - compileOnly("me.lojosho:HibiscusCommons:0.8.0-3fb20b0f") + compileOnly("me.lojosho:HibiscusCommons:0.8.1-d9fbae1d") // Handled by Spigot Library Loader compileOnly("net.kyori:adventure-api:4.24.0") diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java index 4bab0edc..9078ec4e 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/util/packets/HMCCPacketManager.java @@ -5,6 +5,7 @@ import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot; import com.hibiscusmc.hmccosmetics.user.CosmeticUser; import com.hibiscusmc.hmccosmetics.user.CosmeticUsers; import com.hibiscusmc.hmccosmetics.util.HMCCInventoryUtils; +import me.lojosho.hibiscuscommons.nms.MinecraftVersion; import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.util.packets.PacketManager; import org.bukkit.Location; @@ -19,7 +20,10 @@ import org.jetbrains.annotations.NotNull; import org.joml.Quaternionf; import org.joml.Vector3f; -import java.util.*; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.UUID; public class HMCCPacketManager extends PacketManager { @@ -202,22 +206,6 @@ public class HMCCPacketManager extends PacketManager { sendRidingPacket(mountId, new int[] {passengerId}, sendTo); } - /** - * - * @param location Location of the fake player. - * @param uuid UUID of the fake player. Should be random. - * @param entityId The entityID that the entity will take on. - * @param sendTo Who should it send the packet to? - */ - public static void sendFakePlayerSpawnPacket( - final @NotNull Location location, - final UUID uuid, - final int entityId, - final @NotNull List sendTo - ) { - sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid, sendTo); - } - /** * Creates a fake player entity. * @param skinnedPlayer The original player it bases itself off of. @@ -243,19 +231,10 @@ public class HMCCPacketManager extends PacketManager { final int playerId, final @NotNull List sendTo ) { - /* - 0x01 = Is on fire - 0x02 = Is courching - 0x04 = Unusued - 0x08 = Sprinting - 0x10 = Is swimming - 0x20 = Invisibile - 0x40 = Is Glowing - 0x80 = Is flying with an elytra - https://wiki.vg/Entity_metadata#Entity - */ + // https://minecraft.wiki/w/Java_Edition_protocol/Entity_metadata#Avatar final byte mask = 0x01 | 0x02 | 0x04 | 0x08 | 0x010 | 0x020 | 0x40; - NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(playerId, Map.of(17, mask), sendTo); + if (NMSHandlers.getVersion().isLowerOrEqual(MinecraftVersion.v1_21_8)) NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(playerId, Map.of(17, mask), sendTo); + else NMSHandlers.getHandler().getPacketHandler().sendSharedEntityData(playerId, Map.of(16, mask), sendTo); } /**