Skip to content

Commit

Permalink
Fix loading and saving tile entity nbt for 1.16.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Brokkonaut committed Feb 22, 2021
1 parent febef83 commit 24c7f15
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
Expand Up @@ -321,11 +321,11 @@ public void writeTileEntity(Block block, CompoundTag tag) {
if (tileEntity == null) {
return;
}
tileEntity.save(toNativeCompound(tag));
tileEntity.update();
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
WorldServer handle = craftWorld.getHandle();
IBlockData blockData = handle.getType(pos);
tileEntity.load(blockData, toNativeCompound(tag));
tileEntity.update();
craftWorld.getHandle().notify(new BlockPosition(block.getX(), block.getY(), block.getZ()), blockData, blockData, 3);
}

Expand All @@ -337,9 +337,8 @@ public CompoundTag readTileEntity(Block block) {
if (tileEntity == null) {
return null;
}
IBlockData blockData = craftWorld.getHandle().getType(pos);
NBTTagCompound tag = new NBTTagCompound();
tileEntity.load(blockData, tag);
tileEntity.save(tag);
return fromNativeCompound(tag);
}

Expand Down
Expand Up @@ -321,11 +321,11 @@ public void writeTileEntity(Block block, CompoundTag tag) {
if (tileEntity == null) {
return;
}
tileEntity.save(toNativeCompound(tag));
tileEntity.update();
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
WorldServer handle = craftWorld.getHandle();
IBlockData blockData = handle.getType(pos);
tileEntity.load(blockData, toNativeCompound(tag));
tileEntity.update();
craftWorld.getHandle().notify(new BlockPosition(block.getX(), block.getY(), block.getZ()), blockData, blockData, 3);
}

Expand All @@ -337,9 +337,8 @@ public CompoundTag readTileEntity(Block block) {
if (tileEntity == null) {
return null;
}
IBlockData blockData = craftWorld.getHandle().getType(pos);
NBTTagCompound tag = new NBTTagCompound();
tileEntity.load(blockData, tag);
tileEntity.save(tag);
return fromNativeCompound(tag);
}

Expand Down
Expand Up @@ -321,11 +321,11 @@ public void writeTileEntity(Block block, CompoundTag tag) {
if (tileEntity == null) {
return;
}
tileEntity.save(toNativeCompound(tag));
tileEntity.update();
BlockPosition pos = new BlockPosition(block.getX(), block.getY(), block.getZ());
WorldServer handle = craftWorld.getHandle();
IBlockData blockData = handle.getType(pos);
tileEntity.load(blockData, toNativeCompound(tag));
tileEntity.update();
craftWorld.getHandle().notify(new BlockPosition(block.getX(), block.getY(), block.getZ()), blockData, blockData, 3);
}

Expand All @@ -337,9 +337,8 @@ public CompoundTag readTileEntity(Block block) {
if (tileEntity == null) {
return null;
}
IBlockData blockData = craftWorld.getHandle().getType(pos);
NBTTagCompound tag = new NBTTagCompound();
tileEntity.load(blockData, tag);
tileEntity.save(tag);
return fromNativeCompound(tag);
}

Expand Down

0 comments on commit 24c7f15

Please sign in to comment.