Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-18 04:20:08 +01:00
Recover spawn egg data from UNSPECIFIC meta.
Dieser Commit ist enthalten in:
Ursprung
bf8303f25d
Commit
a6d8fa2eac
@ -224,6 +224,7 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||||||
|
|
||||||
private static final Set<String> HANDLED_TAGS = Sets.newHashSet();
|
private static final Set<String> HANDLED_TAGS = Sets.newHashSet();
|
||||||
|
|
||||||
|
private NBTTagCompound internalTag;
|
||||||
private final Map<String, NBTBase> unhandledTags = new HashMap<String, NBTBase>();
|
private final Map<String, NBTBase> unhandledTags = new HashMap<String, NBTBase>();
|
||||||
|
|
||||||
CraftMetaItem(CraftMetaItem meta) {
|
CraftMetaItem(CraftMetaItem meta) {
|
||||||
@ -245,6 +246,11 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||||||
this.hideFlag = meta.hideFlag;
|
this.hideFlag = meta.hideFlag;
|
||||||
this.unbreakable = meta.unbreakable;
|
this.unbreakable = meta.unbreakable;
|
||||||
this.unhandledTags.putAll(meta.unhandledTags);
|
this.unhandledTags.putAll(meta.unhandledTags);
|
||||||
|
|
||||||
|
this.internalTag = meta.internalTag;
|
||||||
|
if (this.internalTag != null) {
|
||||||
|
deserializeInternal(internalTag);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CraftMetaItem(NBTTagCompound tag) {
|
CraftMetaItem(NBTTagCompound tag) {
|
||||||
@ -388,12 +394,12 @@ class CraftMetaItem implements ItemMeta, Repairable {
|
|||||||
if (internal != null) {
|
if (internal != null) {
|
||||||
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal));
|
ByteArrayInputStream buf = new ByteArrayInputStream(Base64.decodeBase64(internal));
|
||||||
try {
|
try {
|
||||||
NBTTagCompound tag = NBTCompressedStreamTools.a(buf);
|
internalTag = NBTCompressedStreamTools.a(buf);
|
||||||
deserializeInternal(tag);
|
deserializeInternal(internalTag);
|
||||||
Set<String> keys = tag.c();
|
Set<String> keys = internalTag.c();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
if (!getHandledTags().contains(key)) {
|
if (!getHandledTags().contains(key)) {
|
||||||
unhandledTags.put(key, tag.get(key));
|
unhandledTags.put(key, internalTag.get(key));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
|
@ -3,7 +3,9 @@ package org.bukkit.craftbukkit.inventory;
|
|||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
import com.google.common.collect.ImmutableMap.Builder;
|
import com.google.common.collect.ImmutableMap.Builder;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import net.minecraft.server.DataConverterTypes;
|
||||||
import net.minecraft.server.MinecraftKey;
|
import net.minecraft.server.MinecraftKey;
|
||||||
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.NBTTagCompound;
|
import net.minecraft.server.NBTTagCompound;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
import org.bukkit.configuration.serialization.DelegateDeserialization;
|
||||||
@ -50,6 +52,20 @@ public class CraftMetaSpawnEgg extends CraftMetaItem implements SpawnEggMeta {
|
|||||||
setSpawnedType(EntityType.fromName(entityType));
|
setSpawnedType(EntityType.fromName(entityType));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
void deserializeInternal(NBTTagCompound tag) {
|
||||||
|
super.deserializeInternal(tag);
|
||||||
|
|
||||||
|
if (tag.hasKey(ENTITY_TAG.NBT)) {
|
||||||
|
entityTag = tag.getCompound(ENTITY_TAG.NBT);
|
||||||
|
MinecraftServer.getServer().getDataConverterManager().a(DataConverterTypes.ENTITY, entityTag); // PAIL: convert
|
||||||
|
|
||||||
|
if (entityTag.hasKey(ENTITY_ID.NBT)) {
|
||||||
|
this.spawnedType = EntityType.fromName(new MinecraftKey(entityTag.getString(ENTITY_ID.NBT)).a()); // PAIL: rename
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
void applyToItem(NBTTagCompound tag) {
|
void applyToItem(NBTTagCompound tag) {
|
||||||
super.applyToItem(tag);
|
super.applyToItem(tag);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren