Skip to content

Commit b7880c2

Browse files
committed
Lazify some more conversions
1 parent b67fff6 commit b7880c2

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BaseBlock.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public BlockType getBlockType() {
100100

101101
@Override
102102
public <V> BaseBlock with(Property<V> property, V value) {
103-
return this.blockState.with(property, value).toBaseBlock(getNbt());
103+
return this.blockState.with(property, value).toBaseBlock(getNbtReference());
104104
}
105105

106106
/**

worldedit-fabric/src/main/java/com/sk89q/worldedit/fabric/FabricWorld.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.sk89q.worldedit.util.SideEffect;
5252
import com.sk89q.worldedit.util.SideEffectSet;
5353
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
54+
import com.sk89q.worldedit.util.concurrency.LazyReference;
5455
import com.sk89q.worldedit.util.io.file.SafeFiles;
5556
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
5657
import com.sk89q.worldedit.world.AbstractWorld;
@@ -426,7 +427,7 @@ private void regenForWorld(Region region, Extent extent, ServerWorld serverWorld
426427
if (blockEntity != null) {
427428
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
428429
blockEntity.toTag(tag);
429-
state = state.toBaseBlock(NBTConverter.fromNative(tag));
430+
state = state.toBaseBlock(LazyReference.from(() -> NBTConverter.fromNative(tag)));
430431
}
431432
extent.setBlock(vec, state.toBaseBlock());
432433

@@ -602,7 +603,7 @@ public BaseBlock getFullBlock(BlockVector3 position) {
602603
if (tile != null) {
603604
net.minecraft.nbt.CompoundTag tag = new net.minecraft.nbt.CompoundTag();
604605
tile.toTag(tag);
605-
return getBlock(position).toBaseBlock(NBTConverter.fromNative(tag));
606+
return getBlock(position).toBaseBlock(LazyReference.from(() -> NBTConverter.fromNative(tag)));
606607
} else {
607608
return getBlock(position).toBaseBlock();
608609
}

worldedit-forge/src/main/java/com/sk89q/worldedit/forge/ForgeWorld.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import com.sk89q.worldedit.util.SideEffect;
5252
import com.sk89q.worldedit.util.SideEffectSet;
5353
import com.sk89q.worldedit.util.TreeGenerator.TreeType;
54+
import com.sk89q.worldedit.util.concurrency.LazyReference;
5455
import com.sk89q.worldedit.util.io.file.SafeFiles;
5556
import com.sk89q.worldedit.util.nbt.CompoundBinaryTag;
5657
import com.sk89q.worldedit.world.AbstractWorld;
@@ -437,7 +438,7 @@ private void regenForWorld(Region region, Extent extent, ServerWorld serverWorld
437438
if (blockEntity != null) {
438439
CompoundNBT tag = new CompoundNBT();
439440
blockEntity.write(tag);
440-
state = state.toBaseBlock(NBTConverter.fromNative(tag));
441+
state = state.toBaseBlock(LazyReference.from(() -> NBTConverter.fromNative(tag)));
441442
}
442443
extent.setBlock(vec, state.toBaseBlock());
443444

@@ -610,7 +611,10 @@ public BaseBlock getFullBlock(BlockVector3 position) {
610611
TileEntity tile = getWorld().getChunk(pos).getTileEntity(pos);
611612

612613
if (tile != null) {
613-
return getBlock(position).toBaseBlock(NBTConverter.fromNative(TileEntityUtils.copyNbtData(tile)));
614+
CompoundNBT tag = TileEntityUtils.copyNbtData(tile);
615+
return getBlock(position).toBaseBlock(
616+
LazyReference.from(() -> NBTConverter.fromNative(tag))
617+
);
614618
} else {
615619
return getBlock(position).toBaseBlock();
616620
}

0 commit comments

Comments
 (0)