From 2e2ceab0367ec08e83ed6e0f2fe3f2020b9d642b Mon Sep 17 00:00:00 2001 From: granny Date: Tue, 30 Apr 2024 03:35:20 -0700 Subject: [PATCH] avoid using CustomData#getUnsafe() --- patches/server/0280-Stored-Bee-API.patch | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/patches/server/0280-Stored-Bee-API.patch b/patches/server/0280-Stored-Bee-API.patch index 8c167d448..525c836e8 100644 --- a/patches/server/0280-Stored-Bee-API.patch +++ b/patches/server/0280-Stored-Bee-API.patch @@ -141,16 +141,18 @@ index 1a2a05160ba51d9c75f1ae6ae61d944d81428722..3beb26ad2ef0fded49a8da8c5dec64f9 } diff --git a/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java b/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java new file mode 100644 -index 0000000000000000000000000000000000000000..25d718489a1a589d9754b8a02340cec819eec6d8 +index 0000000000000000000000000000000000000000..7608bf0981fa0d37031e51e57e4086cb5ec4c88b --- /dev/null +++ b/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java -@@ -0,0 +1,103 @@ +@@ -0,0 +1,106 @@ +package org.purpurmc.purpur.entity; + +import io.papermc.paper.adventure.PaperAdventure; +import net.kyori.adventure.text.Component; ++import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.Tag; +import net.minecraft.server.MinecraftServer; ++import net.minecraft.world.item.component.CustomData; +import net.minecraft.world.level.block.entity.BeehiveBlockEntity; +import org.bukkit.block.EntityBlockStorage; +import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; @@ -176,12 +178,13 @@ index 0000000000000000000000000000000000000000..25d718489a1a589d9754b8a02340cec8 + this.handle = data; + this.blockStorage = blockStorage; + -+ this.customName = handle.occupant.entityData().contains("CustomName") -+ ? PaperAdventure.asAdventure(net.minecraft.network.chat.Component.Serializer.fromJson(handle.occupant.entityData().getUnsafe().getString("CustomName"), MinecraftServer.getDefaultRegistryAccess())) ++ CompoundTag customData = handle.occupant.entityData().copyTag(); ++ this.customName = customData.contains("CustomName") ++ ? PaperAdventure.asAdventure(net.minecraft.network.chat.Component.Serializer.fromJson(customData.getString("CustomName"), MinecraftServer.getDefaultRegistryAccess())) + : null; + -+ if(handle.occupant.entityData().getUnsafe().contains("BukkitValues", Tag.TAG_COMPOUND)) { -+ this.persistentDataContainer.putAll(handle.occupant.entityData().getUnsafe().getCompound("BukkitValues")); ++ if(customData.contains("BukkitValues", Tag.TAG_COMPOUND)) { ++ this.persistentDataContainer.putAll(customData.getCompound("BukkitValues")); + } + } +