Skip to content

Commit 7b360b0

Browse files
committed
use world context for registry access
1 parent 10fe084 commit 7b360b0

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

purpur-server/src/main/java/org/purpurmc/purpur/entity/PurpurStoredBee.java

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
import io.papermc.paper.adventure.PaperAdventure;
44
import net.kyori.adventure.text.Component;
55
import net.minecraft.nbt.CompoundTag;
6-
import net.minecraft.nbt.NbtOps;
7-
import net.minecraft.network.chat.ComponentSerialization;
8-
import net.minecraft.server.MinecraftServer;
96
import net.minecraft.world.level.block.entity.BeehiveBlockEntity;
7+
import net.minecraft.world.level.block.entity.BlockEntity;
108
import org.bukkit.block.EntityBlockStorage;
9+
import org.bukkit.craftbukkit.CraftWorld;
1110
import org.bukkit.craftbukkit.persistence.CraftPersistentDataContainer;
1211
import org.bukkit.craftbukkit.persistence.CraftPersistentDataTypeRegistry;
1312
import org.bukkit.entity.Bee;
@@ -32,7 +31,7 @@ public PurpurStoredBee(BeehiveBlockEntity.BeeData data, EntityBlockStorage<Bee>
3231
this.blockStorage = blockStorage;
3332

3433
CompoundTag customData = handle.occupant.entityData().copyTag();
35-
net.minecraft.network.chat.Component customNameMinecraft = customData.read("CustomName", ComponentSerialization.CODEC, MinecraftServer.getDefaultRegistryAccess().createSerializationContext(NbtOps.INSTANCE)).orElse(null);
34+
net.minecraft.network.chat.Component customNameMinecraft = BlockEntity.parseCustomNameSafe(customData.get("CustomName"), ((CraftWorld) blockStorage.getWorld()).getHandle().registryAccess());
3635
this.customName = customNameMinecraft == null ? null : PaperAdventure.asAdventure(customNameMinecraft);
3736

3837
if (customData.get("BukkitValues") instanceof CompoundTag compoundTag) {
@@ -99,7 +98,7 @@ public void update() {
9998
if(customName == null) {
10099
handle.occupant.entityData().copyTag().remove("CustomName");
101100
} else {
102-
handle.occupant.entityData().copyTag().putString("CustomName", net.minecraft.network.chat.Component.Serializer.toJson(PaperAdventure.asVanilla(customName), MinecraftServer.getDefaultRegistryAccess()));
101+
handle.occupant.entityData().copyTag().putString("CustomName", net.minecraft.network.chat.Component.Serializer.toJson(PaperAdventure.asVanilla(customName), ((CraftWorld) blockStorage.getWorld()).getHandle().registryAccess()));
103102
}
104103
}
105104
}

0 commit comments

Comments
 (0)