Prevent nbt copy when placing a block

This commit is contained in:
TheMode 2021-07-10 20:41:22 +02:00
parent 4abc6dd9eb
commit 99d4682655
3 changed files with 9 additions and 2 deletions

View File

@ -55,8 +55,7 @@ public class DynamicChunk extends Chunk {
final int index = ChunkUtils.getBlockIndex(x, y, z);
// Handler
final BlockHandler handler = block.handler();
final NBTCompound nbt = block.nbt();
if (handler != null || nbt != null) {
if (handler != null || block.hasNbt()) {
this.entries.put(index, block);
} else {
this.entries.remove(index);

View File

@ -97,6 +97,9 @@ public interface Block extends ProtocolObject, TagReadable, BlockConstants {
return getTag(Tag.NBT);
}
@Contract(pure = true)
boolean hasNbt();
/**
* Returns the block handler.
*

View File

@ -65,6 +65,11 @@ class BlockImpl implements Block {
return new BlockImpl(registry, properties, nbt, handler);
}
@Override
public boolean hasNbt() {
return nbt != null && nbt.getSize() > 0;
}
@Override
public @Nullable BlockHandler handler() {
return handler;