SPIGOT-6194: Read correct nbt compound into chunk pdc
Previously spigots chunk pdc loading logic would read the entire chunk nbt compound into the persistent data container of the chunk instead of just reading the "BukkitValues". Furthermore this commit also now correctly checks if the nbt compounds of entities, tile entities and chunks actually have a value for the "BukkitValues" key, as the previous 'getCompound' call would always return an instance, the null check was useless. This commit now uses 'get', which returns null if no key exists and then runs an instanceof check to both validate a non-null instance and an NBTTagCompound instance.
This commit is contained in:
parent
4ef13f94d6
commit
9e91bcabf2
@ -23,9 +23,9 @@
|
|||||||
object = new Chunk(worldserver.getMinecraftWorld(), chunkcoordintpair, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, j, achunksection, (chunk) -> {
|
object = new Chunk(worldserver.getMinecraftWorld(), chunkcoordintpair, biomestorage, chunkconverter, (TickList) object1, (TickList) object2, j, achunksection, (chunk) -> {
|
||||||
loadEntities(nbttagcompound1, chunk);
|
loadEntities(nbttagcompound1, chunk);
|
||||||
+ // CraftBukkit start - load chunk persistent data from nbt
|
+ // CraftBukkit start - load chunk persistent data from nbt
|
||||||
+ NBTTagCompound persistentBase = nbttagcompound1.getCompound("BukkitValues");
|
+ NBTBase persistentBase = nbttagcompound1.get("BukkitValues");
|
||||||
+ if (persistentBase != null) {
|
+ if (persistentBase instanceof NBTTagCompound) {
|
||||||
+ chunk.persistentDataContainer.putAll(nbttagcompound1);
|
+ chunk.persistentDataContainer.putAll((NBTTagCompound) persistentBase);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
});
|
});
|
||||||
|
@ -26,9 +26,9 @@
|
|||||||
+ // CraftBukkit start - read container
|
+ // CraftBukkit start - read container
|
||||||
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||||
+
|
+
|
||||||
+ NBTTagCompound persistentDataTag = nbttagcompound.getCompound("PublicBukkitValues");
|
+ NBTBase persistentDataTag = nbttagcompound.get("PublicBukkitValues");
|
||||||
+ if (persistentDataTag != null) {
|
+ if (persistentDataTag instanceof NBTTagCompound) {
|
||||||
+ this.persistentDataContainer.putAll(persistentDataTag);
|
+ this.persistentDataContainer.putAll((NBTTagCompound) persistentDataTag);
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
}
|
}
|
||||||
|
@ -142,6 +142,7 @@ import net.minecraft.server.EntityZombie;
|
|||||||
import net.minecraft.server.EntityZombieHusk;
|
import net.minecraft.server.EntityZombieHusk;
|
||||||
import net.minecraft.server.EntityZombieVillager;
|
import net.minecraft.server.EntityZombieVillager;
|
||||||
import net.minecraft.server.IChatBaseComponent;
|
import net.minecraft.server.IChatBaseComponent;
|
||||||
|
import net.minecraft.server.NBTBase;
|
||||||
import net.minecraft.server.NBTTagCompound;
|
import net.minecraft.server.NBTTagCompound;
|
||||||
import org.bukkit.EntityEffect;
|
import org.bukkit.EntityEffect;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -970,9 +971,9 @@ public abstract class CraftEntity implements org.bukkit.entity.Entity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void readBukkitValues(NBTTagCompound c) {
|
public void readBukkitValues(NBTTagCompound c) {
|
||||||
NBTTagCompound base = c.getCompound("BukkitValues");
|
NBTBase base = c.get("BukkitValues");
|
||||||
if (base != null) {
|
if (base instanceof NBTTagCompound) {
|
||||||
this.persistentDataContainer.putAll(base);
|
this.persistentDataContainer.putAll((NBTTagCompound) base);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user