mirror of
https://github.com/PurpurMC/Purpur.git
synced 2026-02-17 16:37:43 +01:00
use world context for registry access
This commit is contained in:
@@ -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<Bee> {
|
||||
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<Bee> {
|
||||
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()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user