mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 12:36:07 +01:00
SPIGOT-5130: PersistentDataContainer not removing values on TileEntities
This commit is contained in:
parent
bf32933484
commit
491c848210
@ -14,16 +14,18 @@
|
|||||||
|
|
||||||
+ // CraftBukkit start - data containers
|
+ // CraftBukkit start - data containers
|
||||||
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
+ private static final CraftPersistentDataTypeRegistry DATA_TYPE_REGISTRY = new CraftPersistentDataTypeRegistry();
|
||||||
+ public final CraftPersistentDataContainer persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
+ public CraftPersistentDataContainer persistentDataContainer;
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
private static final Logger LOGGER = LogManager.getLogger();
|
private static final Logger LOGGER = LogManager.getLogger();
|
||||||
private final TileEntityTypes<?> b;
|
private final TileEntityTypes<?> b;
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -37,6 +46,12 @@
|
@@ -37,6 +46,14 @@
|
||||||
|
|
||||||
public void load(NBTTagCompound nbttagcompound) {
|
public void load(NBTTagCompound nbttagcompound) {
|
||||||
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
this.position = new BlockPosition(nbttagcompound.getInt("x"), nbttagcompound.getInt("y"), nbttagcompound.getInt("z"));
|
||||||
+ // CraftBukkit start - read container
|
+ // CraftBukkit start - read container
|
||||||
|
+ this.persistentDataContainer = new CraftPersistentDataContainer(DATA_TYPE_REGISTRY);
|
||||||
|
+
|
||||||
+ NBTTagCompound persistentDataTag = nbttagcompound.getCompound("PublicBukkitValues");
|
+ NBTTagCompound persistentDataTag = nbttagcompound.getCompound("PublicBukkitValues");
|
||||||
+ if (persistentDataTag != null) {
|
+ if (persistentDataTag != null) {
|
||||||
+ this.persistentDataContainer.putAll(persistentDataTag);
|
+ this.persistentDataContainer.putAll(persistentDataTag);
|
||||||
@ -32,12 +34,12 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
public NBTTagCompound save(NBTTagCompound nbttagcompound) {
|
||||||
@@ -53,12 +68,24 @@
|
@@ -53,12 +70,24 @@
|
||||||
nbttagcompound.setInt("x", this.position.getX());
|
nbttagcompound.setInt("x", this.position.getX());
|
||||||
nbttagcompound.setInt("y", this.position.getY());
|
nbttagcompound.setInt("y", this.position.getY());
|
||||||
nbttagcompound.setInt("z", this.position.getZ());
|
nbttagcompound.setInt("z", this.position.getZ());
|
||||||
+ // CraftBukkit start - store container
|
+ // CraftBukkit start - store container
|
||||||
+ if (!this.persistentDataContainer.isEmpty()) {
|
+ if (this.persistentDataContainer != null && !this.persistentDataContainer.isEmpty()) {
|
||||||
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
|
+ nbttagcompound.set("PublicBukkitValues", this.persistentDataContainer.toTagCompound());
|
||||||
+ }
|
+ }
|
||||||
+ // CraftBukkit end
|
+ // CraftBukkit end
|
||||||
@ -57,7 +59,7 @@
|
|||||||
String s = nbttagcompound.getString("id");
|
String s = nbttagcompound.getString("id");
|
||||||
|
|
||||||
return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> {
|
return (TileEntity) IRegistry.BLOCK_ENTITY_TYPE.getOptional(new MinecraftKey(s)).map((tileentitytypes) -> {
|
||||||
@@ -70,6 +97,7 @@
|
@@ -70,6 +99,7 @@
|
||||||
}
|
}
|
||||||
}).map((tileentity) -> {
|
}).map((tileentity) -> {
|
||||||
try {
|
try {
|
||||||
@ -65,7 +67,7 @@
|
|||||||
tileentity.load(nbttagcompound);
|
tileentity.load(nbttagcompound);
|
||||||
return tileentity;
|
return tileentity;
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
@@ -168,4 +196,13 @@
|
@@ -168,4 +198,13 @@
|
||||||
}, this::getPosition});
|
}, this::getPosition});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user