From e3deffac8b96b9281d5078d9546521609c6f64be Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sat, 1 Jun 2024 12:41:10 +0100 Subject: [PATCH] Utilise thread extends when able --- .../core/extent/PassthroughExtent.java | 62 +++++++++++++++++++ .../implementation/ParallelQueueExtent.java | 4 +- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PassthroughExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PassthroughExtent.java index e1e0975d5..7a118d8c1 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PassthroughExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/extent/PassthroughExtent.java @@ -6,6 +6,8 @@ import com.fastasyncworldedit.core.queue.Filter; import com.sk89q.jnbt.CompoundTag; import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.WorldEditException; +import com.sk89q.worldedit.entity.BaseEntity; +import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.clipboard.Clipboard; @@ -15,6 +17,7 @@ import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.util.Countable; +import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; @@ -24,6 +27,7 @@ import com.sk89q.worldedit.world.block.BlockType; import javax.annotation.Nullable; import java.util.List; import java.util.Set; +import java.util.UUID; public class PassthroughExtent extends AbstractDelegateExtent { @@ -193,17 +197,55 @@ public class PassthroughExtent extends AbstractDelegateExtent { return getExtent().getBlock(position); } + @Override + public BlockState getBlock(int x, int y, int z) { + return getExtent().getBlock(x, y, z); + } + @Override public BaseBlock getFullBlock(BlockVector3 position) { return getExtent().getFullBlock(position); } + @Override + public BaseBlock getFullBlock(int x, int y, int z) { + return getExtent().getFullBlock(x, y, z); + } + + @Override + public List getEntities(Region region) { + return getExtent().getEntities(region); + } + + @Override + public List getEntities() { + return getExtent().getEntities(); + } + + @Nullable + @Override + public Entity createEntity(Location location, BaseEntity entity) { + return getExtent().createEntity(location, entity); + } + + @Nullable + @Override + public Entity createEntity(Location location, BaseEntity entity, UUID uuid) { + return getExtent().createEntity(location, entity, uuid); + } + @Override @Deprecated public > boolean setBlock(BlockVector3 position, T block) throws WorldEditException { return getExtent().setBlock(position, block); } + @Override + public > boolean setBlock(int x, int y, int z, T block) throws + WorldEditException { + return getExtent().setBlock(x, y, z, block); + } + @Override public boolean setTile(int x, int y, int z, CompoundTag tile) throws WorldEditException { return getExtent().setTile(x, y, z, tile); @@ -214,11 +256,21 @@ public class PassthroughExtent extends AbstractDelegateExtent { return getExtent().setBiome(position, biome); } + @Override + public boolean setBiome(int x, int y, int z, BiomeType biome) { + return getExtent().setBiome(x, y, z, biome); + } + @Override public boolean cancel() { return getExtent().cancel(); } + @Override + public void removeEntity(int x, int y, int z, UUID uuid) { + getExtent().removeEntity(x, y, z, uuid); + } + @Override public boolean isQueueEnabled() { return getExtent().isQueueEnabled(); @@ -244,6 +296,16 @@ public class PassthroughExtent extends AbstractDelegateExtent { return getExtent().apply(region, filter, full); } + @Override + public BiomeType getBiome(BlockVector3 position) { + return getExtent().getBiome(position); + } + + @Override + public BiomeType getBiomeType(int x, int y, int z) { + return getExtent().getBiomeType(x, y, z); + } + @Override public T apply(Iterable positions, T filter) { return getExtent().apply(positions, filter); diff --git a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java index e166ca235..591c1bcd0 100644 --- a/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java +++ b/worldedit-core/src/main/java/com/fastasyncworldedit/core/queue/implementation/ParallelQueueExtent.java @@ -221,9 +221,9 @@ public class ParallelQueueExtent extends PassthroughExtent { return new Operation() { @Override public Operation resume(final RunContext run) throws WorldEditException { - getExtent().commit(); + extent.commit(); processor.flush(); - getExtent().flush(); + ((IQueueExtent>) extent).flush(); return null; }