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); final int index = ChunkUtils.getBlockIndex(x, y, z);
// Handler // Handler
final BlockHandler handler = block.handler(); final BlockHandler handler = block.handler();
final NBTCompound nbt = block.nbt(); if (handler != null || block.hasNbt()) {
if (handler != null || nbt != null) {
this.entries.put(index, block); this.entries.put(index, block);
} else { } else {
this.entries.remove(index); this.entries.remove(index);

View File

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

View File

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