mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 09:47:38 +00:00
More upstream changes to clipboard
This commit is contained in:
parent
a8538b25a3
commit
1ed4118319
@ -1,7 +1,5 @@
|
|||||||
package com.boydti.fawe.beta;
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
|
||||||
|
|
||||||
public interface IQueueWrapper {
|
public interface IQueueWrapper {
|
||||||
default IQueueExtent<IQueueChunk> wrapQueue(IQueueExtent<IQueueChunk> queue) {
|
default IQueueExtent<IQueueChunk> wrapQueue(IQueueExtent<IQueueChunk> queue) {
|
||||||
return queue;
|
return queue;
|
||||||
|
@ -214,16 +214,4 @@ public class CPUOptimizedClipboard extends LinearClipboard {
|
|||||||
this.entities.remove(entity);
|
this.entities.remove(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
|
||||||
Iterator<BlockArrayClipboard.ClipboardEntity> iter = this.entities.iterator();
|
|
||||||
while (iter.hasNext()) {
|
|
||||||
BlockArrayClipboard.ClipboardEntity entity = iter.next();
|
|
||||||
UUID entUUID = entity.getState().getNbtData().getUUID();
|
|
||||||
if (uuid.equals(entUUID)) {
|
|
||||||
iter.remove();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -40,7 +40,6 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.io.Closeable;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -52,10 +51,10 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* Stores block data as a multi-dimensional array of {@link BlockState}s and
|
* Stores block data as a multi-dimensional array of {@link BlockState}s and
|
||||||
* other data as lists or maps.
|
* other data as lists or maps.
|
||||||
*/
|
*/
|
||||||
public class BlockArrayClipboard extends DelegateClipboard implements Clipboard, Closeable {
|
public class BlockArrayClipboard extends DelegateClipboard implements Clipboard {
|
||||||
|
|
||||||
private Region region;
|
private final Region region;
|
||||||
private BlockVector3 offset;
|
private final BlockVector3 origin;
|
||||||
|
|
||||||
public BlockArrayClipboard(Region region) {
|
public BlockArrayClipboard(Region region) {
|
||||||
this(region, UUID.randomUUID());
|
this(region, UUID.randomUUID());
|
||||||
@ -65,7 +64,8 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
super(clipboard);
|
super(clipboard);
|
||||||
Region shifted = clipboard.getRegion();
|
Region shifted = clipboard.getRegion();
|
||||||
shifted.shift(offset);
|
shifted.shift(offset);
|
||||||
setRegion(shifted);
|
this.region = shifted;
|
||||||
|
this.origin = shifted.getMinimumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -82,7 +82,8 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
public BlockArrayClipboard(Region region, Clipboard clipboard) {
|
public BlockArrayClipboard(Region region, Clipboard clipboard) {
|
||||||
super(clipboard);
|
super(clipboard);
|
||||||
checkNotNull(region);
|
checkNotNull(region);
|
||||||
setRegion(region);
|
this.region = region;
|
||||||
|
this.origin = region.getMinimumPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -90,11 +91,6 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
return region;
|
return region;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRegion(Region region) {
|
|
||||||
this.region = region;
|
|
||||||
this.offset = region.getMinimumPoint();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getOrigin() {
|
public BlockVector3 getOrigin() {
|
||||||
return getParent().getOrigin().add(region.getMinimumPoint());
|
return getParent().getOrigin().add(region.getMinimumPoint());
|
||||||
@ -119,9 +115,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
if (region.contains(position)) {
|
if (region.contains(position)) {
|
||||||
int x = position.getBlockX()- offset.getX();
|
int x = position.getBlockX()- origin.getX();
|
||||||
int y = position.getBlockY()- offset.getY();
|
int y = position.getBlockY()- origin.getY();
|
||||||
int z = position.getBlockZ()- offset.getZ();
|
int z = position.getBlockZ()- origin.getZ();
|
||||||
return getParent().getBlock(x, y, z);
|
return getParent().getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,9 +127,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
if(region.contains(position)) {
|
if(region.contains(position)) {
|
||||||
int x = position.getBlockX()- offset.getX();
|
int x = position.getBlockX()- origin.getX();
|
||||||
int y = position.getBlockY()- offset.getY();
|
int y = position.getBlockY()- origin.getY();
|
||||||
int z = position.getBlockZ()- offset.getZ();
|
int z = position.getBlockZ()- origin.getZ();
|
||||||
return getParent().getFullBlock(x, y, z);
|
return getParent().getFullBlock(x, y, z);
|
||||||
}
|
}
|
||||||
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
return BlockTypes.AIR.getDefaultState().toBaseBlock();
|
||||||
@ -152,9 +148,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().setTile(x, y, z, tag);
|
return getParent().setTile(x, y, z, tag);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -164,9 +160,9 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) throws WorldEditException {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().setBlock(x, y, z, block);
|
return getParent().setBlock(x, y, z, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -183,23 +179,23 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
int x = position.getBlockX() - offset.getX();
|
int x = position.getBlockX() - origin.getX();
|
||||||
int z = position.getBlockZ() - offset.getZ();
|
int z = position.getBlockZ() - origin.getZ();
|
||||||
return getParent().setBiome(x, 0, z, biome);
|
return getParent().setBiome(x, 0, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().setBiome(x, y, z, biome);
|
return getParent().setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
region = region.clone();
|
region = region.clone();
|
||||||
region.shift(BlockVector3.ZERO.subtract(offset));
|
region.shift(BlockVector3.ZERO.subtract(origin));
|
||||||
return getParent().getEntities(region);
|
return getParent().getEntities(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -211,39 +207,39 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void removeEntity(int x, int y, int z, UUID uuid) {
|
public void removeEntity(int x, int y, int z, UUID uuid) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
getParent().removeEntity(x, y, z, uuid);
|
getParent().removeEntity(x, y, z, uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().getBlock(x, y, z);
|
return getParent().getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
y -= offset.getY();
|
y -= origin.getY();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().getFullBlock(x, y, z);
|
return getParent().getFullBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiomeType(int x, int y, int z) {
|
public BiomeType getBiomeType(int x, int y, int z) {
|
||||||
x -= offset.getX();
|
x -= origin.getX();
|
||||||
z -= offset.getZ();
|
z -= origin.getZ();
|
||||||
return getParent().getBiomeType(x, y, z);
|
return getParent().getBiomeType(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator() {
|
public Iterator<BlockVector3> iterator() {
|
||||||
OffsetBlockVector3 mutable = new OffsetBlockVector3(offset);
|
OffsetBlockVector3 mutable = new OffsetBlockVector3(origin);
|
||||||
return Iterators.transform(getParent().iterator(), mutable::init);
|
return Iterators.transform(getParent().iterator(), mutable::init);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,12 +247,12 @@ public class BlockArrayClipboard extends DelegateClipboard implements Clipboard,
|
|||||||
public Iterator<BlockVector2> iterator2d() {
|
public Iterator<BlockVector2> iterator2d() {
|
||||||
MutableBlockVector2 mutable = new MutableBlockVector2();
|
MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||||
return Iterators.transform(getParent().iterator2d(), input ->
|
return Iterators.transform(getParent().iterator2d(), input ->
|
||||||
mutable.setComponents(input.getX() + offset.getX(), input.getZ() + offset.getZ()));
|
mutable.setComponents(input.getX() + origin.getX(), input.getZ() + origin.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Iterator<BlockVector3> iterator(Order order) {
|
public Iterator<BlockVector3> iterator(Order order) {
|
||||||
OffsetBlockVector3 mutable = new OffsetBlockVector3(offset);
|
OffsetBlockVector3 mutable = new OffsetBlockVector3(origin);
|
||||||
return Iterators.transform(getParent().iterator(order), mutable::init);
|
return Iterators.transform(getParent().iterator(order), mutable::init);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user