From d9fbae1dd4312315b66a6aefdcf56034e7963a38 Mon Sep 17 00:00:00 2001 From: Logan <37521985+LoJoSho@users.noreply.github.com> Date: Mon, 10 Nov 2025 16:45:20 -0600 Subject: [PATCH] fix: multimap stuff for 1.21.10 --- common/build.gradle.kts | 2 +- .../util/packets/PacketManager.java | 21 +++++++++++++++++++ .../nms/v1_21_R6/NMSPackets.java | 13 +++++++++--- 3 files changed, 32 insertions(+), 4 deletions(-) diff --git a/common/build.gradle.kts b/common/build.gradle.kts index ff2d9a1..d03c088 100644 --- a/common/build.gradle.kts +++ b/common/build.gradle.kts @@ -17,5 +17,5 @@ tasks { } dependencies { - compileOnly("io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT") + compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT") } \ No newline at end of file diff --git a/common/src/main/java/me/lojosho/hibiscuscommons/util/packets/PacketManager.java b/common/src/main/java/me/lojosho/hibiscuscommons/util/packets/PacketManager.java index fe9e60c..fd107d7 100644 --- a/common/src/main/java/me/lojosho/hibiscuscommons/util/packets/PacketManager.java +++ b/common/src/main/java/me/lojosho/hibiscuscommons/util/packets/PacketManager.java @@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util.packets; import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntList; +import me.lojosho.hibiscuscommons.nms.MinecraftVersion; import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.util.MessagesUtil; import org.bukkit.GameMode; @@ -171,6 +172,26 @@ public class PacketManager { NMSHandlers.getHandler().getPacketHandler().sendEquipmentSlotUpdate(entityId, equipment, 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); + /* Data structure is different for Mannequins + if (NMSHandlers.getVersion().isLower(MinecraftVersion.v1_21_9)) sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid, sendTo); + else sendEntitySpawnPacket(location, entityId, EntityType.MANNEQUIN, uuid, sendTo); + */ + } + private static List getNearbyPlayers(Location location, int distance) { List players = new ArrayList<>(); for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) { diff --git a/v1_21_R6/src/main/java/me/lojosho/hibiscuscommons/nms/v1_21_R6/NMSPackets.java b/v1_21_R6/src/main/java/me/lojosho/hibiscuscommons/nms/v1_21_R6/NMSPackets.java index 571c53d..aa44977 100644 --- a/v1_21_R6/src/main/java/me/lojosho/hibiscuscommons/nms/v1_21_R6/NMSPackets.java +++ b/v1_21_R6/src/main/java/me/lojosho/hibiscuscommons/nms/v1_21_R6/NMSPackets.java @@ -1,10 +1,11 @@ package me.lojosho.hibiscuscommons.nms.v1_21_R6; -import com.google.common.collect.ImmutableList; +import com.google.common.collect.*; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.mojang.authlib.GameProfile; import com.mojang.authlib.properties.Property; +import com.mojang.authlib.properties.PropertyMap; import com.mojang.datafixers.util.Pair; import com.mojang.serialization.JsonOps; import io.papermc.paper.adventure.PaperAdventure; @@ -96,8 +97,14 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons. if (name.length() > 15) name = name.substring(0, 15); Property property = ((CraftPlayer) skinnedPlayer).getProfile().properties().get("textures").stream().findAny().orElse(null); - GameProfile profile = new GameProfile(uuid, name); - if (property != null) profile.properties().put("textures", property); + final Multimap multimaps = MultimapBuilder.hashKeys().arrayListValues().build(((CraftPlayer) skinnedPlayer).getProfile().properties()); + if (property != null) { + multimaps.removeAll("textures"); + multimaps.put("textures", property); + } + + PropertyMap map = new PropertyMap(multimaps); + GameProfile profile = new GameProfile(uuid, name, map); Component component = AdventureUtils.MINI_MESSAGE.deserialize(name); net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);