From 7b360b0c86207b14ff1cc9b7d264821302219aa7 Mon Sep 17 00:00:00 2001 From: granny Date: Sat, 29 Mar 2025 16:51:19 -0700 Subject: [PATCH] use world context for registry access --- .../java/org/purpurmc/purpur/entity/PurpurStoredBee.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/purpur-server/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java b/purpur-server/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java index 859164a73..1cd79edbe 100644 --- a/purpur-server/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java +++ b/purpur-server/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java @@ -3,11 +3,10 @@ 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.NbtOps; -import net.minecraft.network.chat.ComponentSerialization; -import net.minecraft.server.MinecraftServer; import net.minecraft.world.level.block.entity.BeehiveBlockEntity; +import net.minecraft.world.level.block.entity.BlockEntity; import org.bukkit.block.EntityBlockStorage; +import org.bukkit.craftbukkit.CraftWorld; import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer; import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry; import org.bukkit.entity.Bee; @@ -32,7 +31,7 @@ public class PurpurStoredBee implements StoredEntity { this.blockStorage = blockStorage; CompoundTag customData = handle.occupant.entityData().copyTag(); - net.minecraft.network.chat.Component customNameMinecraft = customData.read("CustomName", ComponentSerialization.CODEC, MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE)).orElse(null); + net.minecraft.network.chat.Component customNameMinecraft = BlockEntity.parseCustomNameSafe(customData.get("CustomName"), ((CraftWorld) blockStorage.getWorld()).getHandle().registryAccess()); this.customName = customNameMinecraft == null ? null : PaperAdventure.asAdventure(customNameMinecraft); if (customData.get("BukkitValues") instanceof CompoundTag compoundTag) { @@ -99,7 +98,7 @@ public class PurpurStoredBee implements StoredEntity { if(customName == null) { handle.occupant.entityData().copyTag().remove("CustomName"); } else { - handle.occupant.entityData().copyTag().putString("CustomName", net.minecraft.network.chat.Component.Serializer.toJson(PaperAdventure.asVanilla(customName), MinecraftServer.getDefaultRegistryAccess())); + handle.occupant.entityData().copyTag().putString("CustomName", net.minecraft.network.chat.Component.Serializer.toJson(PaperAdventure.asVanilla(customName), ((CraftWorld) blockStorage.getWorld()).getHandle().registryAccess())); } } }