geforkt von Mirrors/FastAsyncWorldEdit
.
Dieser Commit ist enthalten in:
Ursprung
da034f9ac4
Commit
6bc5b4a823
@ -440,11 +440,6 @@ public class BukkitWorld extends AbstractWorld {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public com.sk89q.worldedit.world.block.BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
BukkitImplAdapter adapter = WorldEditPlugin.getInstance().getBukkitImplAdapter();
|
||||||
|
@ -6,6 +6,8 @@ import com.boydti.fawe.jnbt.anvil.BitArray4096;
|
|||||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.sk89q.jnbt.*;
|
import com.sk89q.jnbt.*;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
@ -33,6 +35,10 @@ public class FaweCache implements Trimable {
|
|||||||
BLOCK_STATES.clean();
|
BLOCK_STATES.clean();
|
||||||
SECTION_BLOCKS.clean();
|
SECTION_BLOCKS.clean();
|
||||||
PALETTE_CACHE.clean();
|
PALETTE_CACHE.clean();
|
||||||
|
PALETTE_TO_BLOCK_CHAR.clean();
|
||||||
|
|
||||||
|
MUTABLE_VECTOR3.clean();
|
||||||
|
MUTABLE_BLOCKVECTOR3.clean();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,6 +195,24 @@ public class FaweCache implements Trimable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Vector cache
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static IterableThreadLocal<MutableBlockVector3> MUTABLE_BLOCKVECTOR3 = new IterableThreadLocal<MutableBlockVector3>() {
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 init() {
|
||||||
|
return new MutableBlockVector3();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
public static IterableThreadLocal<MutableVector3> MUTABLE_VECTOR3 = new IterableThreadLocal<MutableVector3>() {
|
||||||
|
@Override
|
||||||
|
public MutableVector3 init() {
|
||||||
|
return new MutableVector3();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Conversion methods between JNBT tags and raw values
|
Conversion methods between JNBT tags and raw values
|
||||||
*/
|
*/
|
||||||
|
@ -2,13 +2,11 @@ package com.boydti.fawe.beta;
|
|||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import javax.annotation.Nullable;
|
||||||
import java.util.concurrent.ThreadLocalRandom;
|
|
||||||
|
|
||||||
public class ArrayFilterBlock extends SimpleFilterBlock {
|
public class ArrayFilterBlock extends SimpleFilterBlock {
|
||||||
private final char[] blocks;
|
private final char[] blocks;
|
||||||
@ -42,7 +40,7 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setState(BlockState state) {
|
public void setBlock(BlockState state) {
|
||||||
blocks[index] = state.getOrdinalChar();
|
blocks[index] = state.getOrdinalChar();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,20 +55,23 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getState() {
|
public BlockState getBlock() {
|
||||||
return BlockTypes.states[ordinal];
|
return BlockTypes.states[ordinal];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getBaseBlock() {
|
public BaseBlock getFullBlock() {
|
||||||
return getState().toBaseBlock();
|
return getBlock().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompoundTag getTag() {
|
public CompoundTag getNbtData() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNbtData(@Nullable CompoundTag nbtData) {}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getX() {
|
public int getX() {
|
||||||
return x;
|
return x;
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.beta;
|
|||||||
|
|
||||||
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
@ -166,13 +167,18 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(BiomeType biome) {
|
||||||
|
set.setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setOrdinal(final int ordinal) {
|
public void setOrdinal(final int ordinal) {
|
||||||
delegate.set(this, (char) ordinal);
|
delegate.set(this, (char) ordinal);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setState(final BlockState state) {
|
public void setBlock(final BlockState state) {
|
||||||
delegate.set(this, state.getOrdinalChar());
|
delegate.set(this, state.getOrdinalChar());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,28 +241,81 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final BlockState getState() {
|
public final BlockState getBlock() {
|
||||||
final int ordinal = getArr[index];
|
final int ordinal = getArr[index];
|
||||||
return BlockTypes.states[ordinal];
|
return BlockTypes.states[ordinal];
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final BaseBlock getBaseBlock() {
|
public final BaseBlock getFullBlock() {
|
||||||
final BlockState state = getState();
|
final BlockState state = getBlock();
|
||||||
final BlockMaterial material = state.getMaterial();
|
final BlockMaterial material = state.getMaterial();
|
||||||
if (material.hasContainer()) {
|
if (material.hasContainer()) {
|
||||||
final CompoundTag tag = get.getTag(x, y + (layer << 4), z);
|
final CompoundTag tag = get.getTag(x, y + yy, z);
|
||||||
return state.toBaseBlock(tag);
|
return state.toBaseBlock(tag);
|
||||||
}
|
}
|
||||||
return state.toBaseBlock();
|
return state.toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final CompoundTag getTag() {
|
public final CompoundTag getNbtData() {
|
||||||
return get.getTag(x, y + (layer << 4), z);
|
return get.getTag(x, y + (layer << 4), z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState getOrdinalBelow() {
|
@Override
|
||||||
|
public void setNbtData(CompoundTag tag) {
|
||||||
|
if (tag != null) {
|
||||||
|
set.setTile(x, y + yy, z, tag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNbtData() {
|
||||||
|
final BlockState state = getBlock();
|
||||||
|
final BlockMaterial material = state.getMaterial();
|
||||||
|
return material.hasContainer();
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
NORTH(Vector3.at(0, 0, -1), Flag.CARDINAL, 3, 1),
|
||||||
|
EAST(Vector3.at(1, 0, 0), Flag.CARDINAL, 0, 2),
|
||||||
|
SOUTH(Vector3.at(0, 0, 1), Flag.CARDINAL, 1, 3),
|
||||||
|
WEST(Vector3.at(-1, 0, 0), Flag.CARDINAL, 2, 0),
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BlockState getBlockNorth() {
|
||||||
|
if (z > 0) {
|
||||||
|
return states[getArr[index - 16]];
|
||||||
|
}
|
||||||
|
return getExtent().getBlock(getX(), getY(), getZ() - 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BlockState getBlockEast() {
|
||||||
|
if (x < 15) {
|
||||||
|
return states[getArr[index + 1]];
|
||||||
|
}
|
||||||
|
return getExtent().getBlock(getX() + 1, getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BlockState getBlockSouth() {
|
||||||
|
if (z < 15) {
|
||||||
|
return states[getArr[index + 16]];
|
||||||
|
}
|
||||||
|
return getExtent().getBlock(getX(), getY(), getZ() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BlockState getBlockWest() {
|
||||||
|
if (x > 0) {
|
||||||
|
return states[getArr[index - 1]];
|
||||||
|
}
|
||||||
|
return getExtent().getBlock(getX() - 1, getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final BlockState getBlockBelow() {
|
||||||
if (y > 0) {
|
if (y > 0) {
|
||||||
return states[getArr[index - 256]];
|
return states[getArr[index - 256]];
|
||||||
}
|
}
|
||||||
@ -268,7 +327,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return BlockTypes.__RESERVED__.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState getStateAbove() {
|
@Override
|
||||||
|
public final BlockState getBlockAbove() {
|
||||||
if (y < 16) {
|
if (y < 16) {
|
||||||
return states[getArr[index + 256]];
|
return states[getArr[index + 256]];
|
||||||
}
|
}
|
||||||
@ -280,7 +340,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return BlockTypes.__RESERVED__.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState getStateRelativeY(final int y) {
|
@Override
|
||||||
|
public final BlockState getBlockRelativeY(final int y) {
|
||||||
final int newY = this.y + y;
|
final int newY = this.y + y;
|
||||||
final int layerAdd = newY >> 4;
|
final int layerAdd = newY >> 4;
|
||||||
switch (layerAdd) {
|
switch (layerAdd) {
|
||||||
@ -334,135 +395,34 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
return BlockTypes.__RESERVED__.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BlockState getStateRelative(final int x, final int y, final int z) {
|
|
||||||
final int newX = this.x + x;
|
|
||||||
final int newZ = this.z + z;
|
@Override
|
||||||
if (newX >> 4 == 0 && newZ >> 4 == 0) {
|
public BlockVector3 north() {
|
||||||
final int newY = this.y + y;
|
return this.north;
|
||||||
final int layerAdd = newY >> 4;
|
|
||||||
switch (layerAdd) {
|
|
||||||
case 0:
|
|
||||||
return states[getArr[this.index + ((y << 8) + (z << 4) + x)]];
|
|
||||||
case 1:
|
|
||||||
case 2:
|
|
||||||
case 3:
|
|
||||||
case 4:
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
case 9:
|
|
||||||
case 10:
|
|
||||||
case 11:
|
|
||||||
case 12:
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
case 15: {
|
|
||||||
final int newLayer = layer + layerAdd;
|
|
||||||
if (newLayer < 16) {
|
|
||||||
final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
|
|
||||||
return states[get.sections[newLayer].get(get, newLayer, index)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case -1:
|
|
||||||
case -2:
|
|
||||||
case -3:
|
|
||||||
case -4:
|
|
||||||
case -5:
|
|
||||||
case -6:
|
|
||||||
case -7:
|
|
||||||
case -8:
|
|
||||||
case -9:
|
|
||||||
case -10:
|
|
||||||
case -11:
|
|
||||||
case -12:
|
|
||||||
case -13:
|
|
||||||
case -14:
|
|
||||||
case -15: {
|
|
||||||
final int newLayer = layer + layerAdd;
|
|
||||||
if (newLayer >= 0) {
|
|
||||||
final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
|
|
||||||
return states[get.sections[newLayer].get(get, newLayer, index)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
|
||||||
}
|
|
||||||
final int newY = this.y + y + yy;
|
|
||||||
if (newY >= 0 && newY <= 256) {
|
|
||||||
return getExtent().getBlock(xx + newX, newY, this.zz + newZ);
|
|
||||||
}
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public final BaseBlock getFullBlockRelative(final int x, final int y, final int z) {
|
@Override
|
||||||
final int newX = this.x + x;
|
public BlockVector3 east() {
|
||||||
final int newZ = this.z + z;
|
return super.east();
|
||||||
if (newX >> 4 == 0 && newZ >> 4 == 0) {
|
}
|
||||||
final int newY = this.y + y;
|
|
||||||
final int layerAdd = newY >> 4;
|
@Override
|
||||||
BlockState state = BlockTypes.__RESERVED__.getDefaultState();
|
public BlockVector3 south() {
|
||||||
switch (layerAdd) {
|
return super.south();
|
||||||
case 0:
|
}
|
||||||
state = states[getArr[this.index + ((y << 8) + (z << 4) + x)]];
|
|
||||||
break;
|
@Override
|
||||||
case 1:
|
public BlockVector3 west() {
|
||||||
case 2:
|
return super.west();
|
||||||
case 3:
|
}
|
||||||
case 4:
|
|
||||||
case 5:
|
/*
|
||||||
case 6:
|
Extent
|
||||||
case 7:
|
*/
|
||||||
case 8:
|
@Override
|
||||||
case 9:
|
public char getOrdinalChar(Extent orDefault) {
|
||||||
case 10:
|
return getOrdinalChar();
|
||||||
case 11:
|
|
||||||
case 12:
|
|
||||||
case 13:
|
|
||||||
case 14:
|
|
||||||
case 15: {
|
|
||||||
final int newLayer = layer + layerAdd;
|
|
||||||
if (newLayer < 16) {
|
|
||||||
final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
|
|
||||||
state = states[get.sections[newLayer].get(get, newLayer, index)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case -1:
|
|
||||||
case -2:
|
|
||||||
case -3:
|
|
||||||
case -4:
|
|
||||||
case -5:
|
|
||||||
case -6:
|
|
||||||
case -7:
|
|
||||||
case -8:
|
|
||||||
case -9:
|
|
||||||
case -10:
|
|
||||||
case -11:
|
|
||||||
case -12:
|
|
||||||
case -13:
|
|
||||||
case -14:
|
|
||||||
case -15: {
|
|
||||||
final int newLayer = layer + layerAdd;
|
|
||||||
if (newLayer >= 0) {
|
|
||||||
final int index = ((newY & 15) << 8) + (newZ << 4) + newX;
|
|
||||||
state = states[get.sections[newLayer].get(get, newLayer, index)];
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (state.getMaterial().hasContainer()) {
|
|
||||||
final CompoundTag tag = get.getTag(x, y + (layer << 4), z);
|
|
||||||
return state.toBaseBlock(tag);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
final int newY = this.y + y + yy;
|
|
||||||
if (newY >= 0 && newY <= 256) {
|
|
||||||
return getExtent().getFullBlock(xx + newX, newY, this.zz + newZ);
|
|
||||||
}
|
|
||||||
return BlockTypes.__RESERVED__.getDefaultState().toBaseBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -484,7 +444,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
|||||||
@Override
|
@Override
|
||||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
if ((x >> 4) == X && (z >> 4) == Z) {
|
if ((x >> 4) == X && (z >> 4) == Z) {
|
||||||
return set.setBiome(x & 15, z & 15, biome);
|
return set.setBiome(x & 15, y, z & 15, biome);
|
||||||
}
|
}
|
||||||
return getExtent().setBiome(x, y, z, biome);
|
return getExtent().setBiome(x, y, z, biome);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import com.sk89q.worldedit.regions.Region;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class ChunkFilterBlock extends FilterBlock {
|
public abstract class ChunkFilterBlock extends SimpleFilterBlock {
|
||||||
public ChunkFilterBlock(Extent extent) {
|
public ChunkFilterBlock(Extent extent) {
|
||||||
super(extent);
|
super(extent);
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,697 @@
|
|||||||
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
|
import com.boydti.fawe.jnbt.anvil.generator.GenBase;
|
||||||
|
import com.boydti.fawe.jnbt.anvil.generator.Resource;
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.entity.BaseEntity;
|
||||||
|
import com.sk89q.worldedit.entity.Entity;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
|
||||||
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
|
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;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class DelegateFilterBlock extends FilterBlock {
|
||||||
|
private final FilterBlock parent;
|
||||||
|
|
||||||
|
public DelegateFilterBlock(FilterBlock parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent getExtent() {
|
||||||
|
return parent.getExtent();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
parent.setOrdinal(ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(BlockState state) {
|
||||||
|
parent.setBlock(state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFullBlock(BaseBlock block) {
|
||||||
|
parent.setFullBlock(block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
|
parent.setNbtData(nbtData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasNbtData() {
|
||||||
|
return parent.hasNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBiome(BiomeType biome) {
|
||||||
|
parent.setBiome(biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrdinal() {
|
||||||
|
return parent.getOrdinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock() {
|
||||||
|
return parent.getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock() {
|
||||||
|
return parent.getFullBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getNbtData() {
|
||||||
|
return parent.getNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMinimumPoint() {
|
||||||
|
return parent.getMinimumPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMaximumPoint() {
|
||||||
|
return parent.getMaximumPoint();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
|
return parent.getBlock(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
|
return parent.getFullBlock(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockBelow() {
|
||||||
|
return parent.getBlockBelow();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockAbove() {
|
||||||
|
return parent.getBlockAbove();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockNorth() {
|
||||||
|
return parent.getBlockNorth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockEast() {
|
||||||
|
return parent.getBlockEast();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockSouth() {
|
||||||
|
return parent.getBlockSouth();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockWest() {
|
||||||
|
return parent.getBlockWest();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlockRelativeY(int y) {
|
||||||
|
return parent.getBlockRelativeY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getX() {
|
||||||
|
return parent.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getY() {
|
||||||
|
return parent.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getZ() {
|
||||||
|
return parent.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLocalX() {
|
||||||
|
return parent.getLocalX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLocalY() {
|
||||||
|
return parent.getLocalY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getLocalZ() {
|
||||||
|
return parent.getLocalZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChunkX() {
|
||||||
|
return parent.getChunkX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getChunkZ() {
|
||||||
|
return parent.getChunkZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setOrdinal(Extent orDefault, int ordinal) {
|
||||||
|
return parent.setOrdinal(orDefault, ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBlock(Extent orDefault, BlockState state) {
|
||||||
|
return parent.setBlock(orDefault, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
|
||||||
|
return parent.setFullBlock(orDefault, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||||
|
return parent.setBiome(orDefault, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrdinal(Extent orDefault) {
|
||||||
|
return parent.getOrdinal(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(Extent orDefault) {
|
||||||
|
return parent.getBlock(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(Extent orDefault) {
|
||||||
|
return parent.getFullBlock(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getNbtData(Extent orDefault) {
|
||||||
|
return parent.getNbtData(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getOrdinalBelow(Extent orDefault) {
|
||||||
|
return parent.getOrdinalBelow(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateAbove(Extent orDefault) {
|
||||||
|
return parent.getStateAbove(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getStateRelativeY(Extent orDefault, int y) {
|
||||||
|
return parent.getStateRelativeY(orDefault, y);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockVector3 at(double x, double y, double z) {
|
||||||
|
return BlockVector3.at(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BlockVector3 at(int x, int y, int z) {
|
||||||
|
return BlockVector3.at(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Comparator<BlockVector3> sortByCoordsYzx() {
|
||||||
|
return BlockVector3.sortByCoordsYzx();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 setComponents(double x, double y, double z) {
|
||||||
|
return parent.setComponents(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 setComponents(int x, int y, int z) {
|
||||||
|
return parent.setComponents(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutX(double x) {
|
||||||
|
return parent.mutX(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutY(double y) {
|
||||||
|
return parent.mutY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutZ(double z) {
|
||||||
|
return parent.mutZ(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutX(int x) {
|
||||||
|
return parent.mutX(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutY(int y) {
|
||||||
|
return parent.mutY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public MutableBlockVector3 mutZ(int z) {
|
||||||
|
return parent.mutZ(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 toImmutable() {
|
||||||
|
return parent.toImmutable();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 north() {
|
||||||
|
return parent.north();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 east() {
|
||||||
|
return parent.east();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 south() {
|
||||||
|
return parent.south();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 west() {
|
||||||
|
return parent.west();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockX() {
|
||||||
|
return parent.getBlockX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 withX(int x) {
|
||||||
|
return parent.withX(x);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockY() {
|
||||||
|
return parent.getBlockY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 withY(int y) {
|
||||||
|
return parent.withY(y);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getBlockZ() {
|
||||||
|
return parent.getBlockZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 withZ(int z) {
|
||||||
|
return parent.withZ(z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 add(BlockVector3 other) {
|
||||||
|
return parent.add(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 add(int x, int y, int z) {
|
||||||
|
return parent.add(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 add(BlockVector3... others) {
|
||||||
|
return parent.add(others);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 subtract(BlockVector3 other) {
|
||||||
|
return parent.subtract(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 subtract(int x, int y, int z) {
|
||||||
|
return parent.subtract(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 subtract(BlockVector3... others) {
|
||||||
|
return parent.subtract(others);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 multiply(BlockVector3 other) {
|
||||||
|
return parent.multiply(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 multiply(int x, int y, int z) {
|
||||||
|
return parent.multiply(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 multiply(BlockVector3... others) {
|
||||||
|
return parent.multiply(others);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 multiply(int n) {
|
||||||
|
return parent.multiply(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 divide(BlockVector3 other) {
|
||||||
|
return parent.divide(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 divide(int x, int y, int z) {
|
||||||
|
return parent.divide(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 divide(int n) {
|
||||||
|
return parent.divide(n);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double length() {
|
||||||
|
return parent.length();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int lengthSq() {
|
||||||
|
return parent.lengthSq();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double distance(BlockVector3 other) {
|
||||||
|
return parent.distance(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int distanceSq(BlockVector3 other) {
|
||||||
|
return parent.distanceSq(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 normalize() {
|
||||||
|
return parent.normalize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double dot(BlockVector3 other) {
|
||||||
|
return parent.dot(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 cross(BlockVector3 other) {
|
||||||
|
return parent.cross(other);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containedWithin(BlockVector3 min, BlockVector3 max) {
|
||||||
|
return parent.containedWithin(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 clampY(int min, int max) {
|
||||||
|
return parent.clampY(min, max);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 floor() {
|
||||||
|
return parent.floor();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 ceil() {
|
||||||
|
return parent.ceil();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 round() {
|
||||||
|
return parent.round();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 abs() {
|
||||||
|
return parent.abs();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 transform2D(double angle, double aboutX, double aboutZ, double translateX, double translateZ) {
|
||||||
|
return parent.transform2D(angle, aboutX, aboutZ, translateX, translateZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double toPitch() {
|
||||||
|
return parent.toPitch();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double toYaw() {
|
||||||
|
return parent.toYaw();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMinimum(BlockVector3 v2) {
|
||||||
|
return parent.getMinimum(v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMaximum(BlockVector3 v2) {
|
||||||
|
return parent.getMaximum(v2);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public char getOrdinalChar(Extent orDefault) {
|
||||||
|
return parent.getOrdinalChar(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector2 toBlockVector2() {
|
||||||
|
return parent.toBlockVector2();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector3 toVector3() {
|
||||||
|
return parent.toVector3();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode() {
|
||||||
|
return parent.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return parent.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Entity> getEntities(Region region) {
|
||||||
|
return parent.getEntities(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<? extends Entity> getEntities() {
|
||||||
|
return parent.getEntities();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Entity createEntity(Location location, BaseEntity entity) {
|
||||||
|
return parent.createEntity(location, entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY) {
|
||||||
|
return parent.getHighestTerrainBlock(x, z, minY, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getHighestTerrainBlock(int x, int z, int minY, int maxY, Mask filter) {
|
||||||
|
return parent.getHighestTerrainBlock(x, z, minY, maxY, filter);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceLayer(int x, int z, int y, int minY, int maxY) {
|
||||||
|
return parent.getNearestSurfaceLayer(x, z, y, minY, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, boolean ignoreAir) {
|
||||||
|
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, ignoreAir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY) {
|
||||||
|
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax) {
|
||||||
|
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, Mask mask) {
|
||||||
|
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getNearestSurfaceTerrainBlock(int x, int z, int y, int minY, int maxY, int failedMin, int failedMax, boolean ignoreAir) {
|
||||||
|
return parent.getNearestSurfaceTerrainBlock(x, z, y, minY, maxY, failedMin, failedMax, ignoreAir);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCaves(Region region) throws WorldEditException {
|
||||||
|
parent.addCaves(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generate(Region region, GenBase gen) throws WorldEditException {
|
||||||
|
parent.generate(region, gen);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addSchems(Region region, Mask mask, List<ClipboardHolder> clipboards, int rarity, boolean rotate) throws WorldEditException {
|
||||||
|
parent.addSchems(region, mask, clipboards, rarity, rotate);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void spawnResource(Region region, Resource gen, int rarity, int frequency) throws WorldEditException {
|
||||||
|
parent.spawnResource(region, gen, rarity, frequency);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean contains(BlockVector3 pt) {
|
||||||
|
return parent.contains(pt);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOre(Region region, Mask mask, Pattern material, int size, int frequency, int rarity, int minY, int maxY) throws WorldEditException {
|
||||||
|
parent.addOre(region, mask, material, size, frequency, rarity, minY, maxY);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addOres(Region region, Mask mask) throws WorldEditException {
|
||||||
|
parent.addOres(region, mask);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Countable<BlockType>> getBlockDistribution(Region region) {
|
||||||
|
return parent.getBlockDistribution(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Countable<BlockState>> getBlockDistributionWithData(Region region) {
|
||||||
|
return parent.getBlockDistributionWithData(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockArrayClipboard lazyCopy(Region region) {
|
||||||
|
return parent.lazyCopy(region);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Nullable
|
||||||
|
public Operation commit() {
|
||||||
|
return parent.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getMaxY() {
|
||||||
|
return parent.getMaxY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
|
return parent.getBlock(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockType getBlockType(BlockVector3 position) {
|
||||||
|
return parent.getBlockType(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
|
return parent.getFullBlock(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeType getBiome(BlockVector2 position) {
|
||||||
|
return parent.getBiome(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BiomeType getBiome(int x, int z) {
|
||||||
|
return parent.getBiome(x, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
|
||||||
|
return parent.setBlock(position, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public <T extends BlockStateHolder<T>> boolean setBlock(int x, int y, int z, T block) throws WorldEditException {
|
||||||
|
return parent.setBlock(x, y, z, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||||
|
return parent.setBiome(position, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
|
return parent.setBiome(x, y, z, biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getNbtId() {
|
||||||
|
return parent.getNbtId();
|
||||||
|
}
|
||||||
|
}
|
@ -1,38 +1,43 @@
|
|||||||
package com.boydti.fawe.beta;
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class FilterBlock extends BlockVector3 implements Extent {
|
import static com.sk89q.worldedit.world.block.BlockTypes.states;
|
||||||
private final Extent extent;
|
|
||||||
|
|
||||||
public FilterBlock(Extent extent) {
|
public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock {
|
||||||
this.extent = extent;
|
public abstract Extent getExtent();
|
||||||
}
|
|
||||||
|
|
||||||
public final Extent getExtent() {
|
|
||||||
return extent;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void setOrdinal(int ordinal);
|
public abstract void setOrdinal(int ordinal);
|
||||||
|
|
||||||
public abstract void setState(BlockState state);
|
public abstract void setBlock(BlockState state);
|
||||||
|
|
||||||
public abstract void setFullBlock(BaseBlock block);
|
public abstract void setFullBlock(BaseBlock block);
|
||||||
|
|
||||||
|
public void setBiome(BiomeType biome) {
|
||||||
|
setBiome(getX(), getY(), getZ(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
public abstract int getOrdinal();
|
public abstract int getOrdinal();
|
||||||
|
|
||||||
public abstract BlockState getState();
|
public abstract BlockState getBlock();
|
||||||
|
|
||||||
public abstract BaseBlock getBaseBlock();
|
public abstract BaseBlock getFullBlock();
|
||||||
|
|
||||||
public abstract CompoundTag getTag();
|
public abstract CompoundTag getNbtData();
|
||||||
|
|
||||||
|
public abstract void setNbtData(@Nullable CompoundTag nbtData);
|
||||||
|
|
||||||
|
public boolean hasNbtData() {
|
||||||
|
return getNbtData() != null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
@ -46,32 +51,40 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return getStateRelative(x - getX(), y - getY(), z - getZ());
|
return getExtent().getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(int x, int y, int z) {
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
return getFullBlockRelative(x - getX(), y - getY(), z - getZ());
|
return getExtent().getFullBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getOrdinalBelow() {
|
public BlockState getBlockBelow() {
|
||||||
return getStateRelative(0, -1, 0);
|
return getBlock(getX(), getY() - 1, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getStateAbove() {
|
public BlockState getBlockAbove() {
|
||||||
return getStateRelative(0, 1, 0);
|
return getBlock(getX(), getY() + 1, getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getStateRelativeY(final int y) {
|
public BlockState getBlockNorth() {
|
||||||
return getStateRelative(0, y, 0);
|
return getBlock(getX(), getY(), getZ() - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getStateRelative(final int x, final int y, final int z) {
|
public BlockState getBlockEast() {
|
||||||
return getFullBlockRelative(x, y, z).toBlockState();
|
return getBlock(getX() + 1, getY(), getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseBlock getFullBlockRelative(int x, int y, int z) {
|
public BlockState getBlockSouth() {
|
||||||
return getExtent().getFullBlock(x + getX(), y + getY(), z + getZ());
|
return getBlock(getX(), getY(), getZ() + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlockWest() {
|
||||||
|
return getBlock(getX() - 1, getY(), getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlockRelativeY(final int y) {
|
||||||
|
return getBlock(getX(), getY() + y , getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -102,4 +115,56 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
|
|||||||
public int getChunkZ() {
|
public int getChunkZ() {
|
||||||
return getZ() >> 4;
|
return getZ() >> 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Extent
|
||||||
|
*/
|
||||||
|
|
||||||
|
public boolean setOrdinal(Extent orDefault, int ordinal) {
|
||||||
|
setOrdinal(ordinal);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Extent orDefault, BlockState state) {
|
||||||
|
setBlock(state);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
|
||||||
|
setFullBlock(block);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||||
|
setBiome(biome);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal(Extent orDefault) {
|
||||||
|
return getOrdinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlock(Extent orDefault) {
|
||||||
|
return getBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseBlock getFullBlock(Extent orDefault) {
|
||||||
|
return getFullBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getNbtData(Extent orDefault) {
|
||||||
|
return getNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getOrdinalBelow(Extent orDefault) {
|
||||||
|
return getBlockBelow();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateAbove(Extent orDefault) {
|
||||||
|
return getBlockAbove();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateRelativeY(Extent orDefault, final int y) {
|
||||||
|
return getBlockRelativeY(y);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -71,7 +71,7 @@ public interface IChunk<T extends Future<T>> extends Trimable, Callable<T> {
|
|||||||
* @param unitialized a mutable block vector (buffer)
|
* @param unitialized a mutable block vector (buffer)
|
||||||
* @param unitialized2 a mutable block vector (buffer)
|
* @param unitialized2 a mutable block vector (buffer)
|
||||||
*/
|
*/
|
||||||
void filter(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2);
|
void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2);
|
||||||
|
|
||||||
void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
|
void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block);
|
||||||
|
|
||||||
|
@ -2,10 +2,12 @@ package com.boydti.fawe.beta;
|
|||||||
|
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.extent.OutputExtent;
|
import com.sk89q.worldedit.extent.OutputExtent;
|
||||||
|
import com.sk89q.worldedit.function.operation.Operation;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -16,7 +18,7 @@ import java.util.UUID;
|
|||||||
* Interface for setting blocks
|
* Interface for setting blocks
|
||||||
*/
|
*/
|
||||||
public interface IChunkSet extends IBlocks, OutputExtent {
|
public interface IChunkSet extends IBlocks, OutputExtent {
|
||||||
boolean setBiome(int x, int z, BiomeType biome);
|
boolean setBiome(int x, int y, int z, BiomeType biome);
|
||||||
|
|
||||||
boolean setBlock(int x, int y, int z, BlockStateHolder holder);
|
boolean setBlock(int x, int y, int z, BlockStateHolder holder);
|
||||||
|
|
||||||
@ -42,4 +44,10 @@ public interface IChunkSet extends IBlocks, OutputExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
@Override
|
||||||
|
default Operation commit() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void flood(Flood flood, FilterBlockMask mask, FilterBlock block) {
|
default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||||
getParent().flood(flood, mask, block);
|
getParent().flood(flood, mask, block);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default void filter(Filter filter, FilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
|
default void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
|
||||||
getParent().filter(filter, block, region, unitialized, unitialized2);
|
getParent().filterBlocks(filter, block, region, unitialized, unitialized2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
93
worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java
Normale Datei
93
worldedit-core/src/main/java/com/boydti/fawe/beta/NorthVector.java
Normale Datei
@ -0,0 +1,93 @@
|
|||||||
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
|
public class NorthVector extends BlockVector3 {
|
||||||
|
private final BlockVector3 parent;
|
||||||
|
|
||||||
|
public NorthVector(BlockVector3 parent) {
|
||||||
|
this.parent = parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 south(BlockVector3 orDefault) {
|
||||||
|
return parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getX() {
|
||||||
|
return parent.getX();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getY() {
|
||||||
|
return parent.getY();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getZ() {
|
||||||
|
return parent.getZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setOrdinal(Extent orDefault, int ordinal) {
|
||||||
|
return orDefault.setBlock(this, BlockState.getFromOrdinal(ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBlock(Extent orDefault, BlockState state) {
|
||||||
|
return orDefault.setBlock(this, state);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setFullBlock(Extent orDefault, BaseBlock block) {
|
||||||
|
return orDefault.setBlock(this, block);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setBiome(Extent orDefault, BiomeType biome) {
|
||||||
|
return orDefault.setBiome(getX(), getY(), getZ(), biome);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getOrdinal(Extent orDefault) {
|
||||||
|
return getBlock(orDefault).getOrdinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getOrdinalChar(Extent orDefault) {
|
||||||
|
return (char) getOrdinal(orDefault);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getBlock(Extent orDefault) {
|
||||||
|
return orDefault.getBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseBlock getFullBlock(Extent orDefault) {
|
||||||
|
return orDefault.getFullBlock(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CompoundTag getNbtData(Extent orDefault) {
|
||||||
|
return orDefault.getFullBlock(getX(), getY(), getZ()).getNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getOrdinalBelow(Extent orDefault) {
|
||||||
|
return getStateRelative(orDefault, 0, -1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateAbove(Extent orDefault) {
|
||||||
|
return getStateRelative(orDefault, 0, 1, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateRelativeY(Extent orDefault, final int y) {
|
||||||
|
return getStateRelative(orDefault, 0, y, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockState getStateRelative(Extent orDefault, final int x, final int y, final int z) {
|
||||||
|
return getFullBlockRelative(orDefault, x, y, z).toBlockState();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BaseBlock getFullBlockRelative(Extent orDefault, int x, int y, int z) {
|
||||||
|
return orDefault.getFullBlock(x + getX(), y + getY(), z + getZ());
|
||||||
|
}
|
||||||
|
}
|
@ -11,60 +11,14 @@ import com.sk89q.worldedit.world.block.BlockTypes;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public abstract class SimpleFilterBlock extends FilterBlock {
|
public abstract class SimpleFilterBlock extends FilterBlock {
|
||||||
|
private final Extent extent;
|
||||||
|
|
||||||
public SimpleFilterBlock(Extent extent) {
|
public SimpleFilterBlock(Extent extent) {
|
||||||
super(extent);
|
this.extent = extent;
|
||||||
}
|
|
||||||
|
|
||||||
private int x, y, z, ordinal;
|
|
||||||
private CompoundTag nbt;
|
|
||||||
|
|
||||||
public void init(int x, int y, int z, int ordinal) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.ordinal = ordinal;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void init(int x, int y, int z, int ordinal, CompoundTag nbt) {
|
|
||||||
this.x = x;
|
|
||||||
this.y = y;
|
|
||||||
this.z = z;
|
|
||||||
this.ordinal = ordinal;
|
|
||||||
this.nbt = nbt;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOrdinal() {
|
public final Extent getExtent() {
|
||||||
return ordinal;
|
return extent;
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getState() {
|
|
||||||
return BlockTypes.states[ordinal];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getBaseBlock() {
|
|
||||||
return getState().toBaseBlock(nbt);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public CompoundTag getTag() {
|
|
||||||
return nbt;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getX() {
|
|
||||||
return x;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getY() {
|
|
||||||
return y;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getZ() {
|
|
||||||
return z;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,98 @@
|
|||||||
|
package com.boydti.fawe.beta;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
public class SingleFilterBlock extends FilterBlock {
|
||||||
|
|
||||||
|
private BaseBlock block;
|
||||||
|
private int x, y, z;
|
||||||
|
|
||||||
|
public SingleFilterBlock init(int x, int y, int z, BaseBlock block) {
|
||||||
|
this.x = x;
|
||||||
|
this.y = y;
|
||||||
|
this.z = z;
|
||||||
|
this.block = block;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Extent getExtent() {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setOrdinal(int ordinal) {
|
||||||
|
setBlock(BlockState.getFromOrdinal(ordinal));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(BlockState state) {
|
||||||
|
setFullBlock(state.toBaseBlock(block.getNbtData()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setFullBlock(BaseBlock block) {
|
||||||
|
this.block = block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setNbtData(@Nullable CompoundTag nbtData) {
|
||||||
|
block = block.toBaseBlock(nbtData);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getOrdinal() {
|
||||||
|
return block.getOrdinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlockRelative(int x, int y, int z) {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock() {
|
||||||
|
return block.toBlockState();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock() {
|
||||||
|
return block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompoundTag getNbtData() {
|
||||||
|
return block.getNbtData();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getX() {
|
||||||
|
return x;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getY() {
|
||||||
|
return y;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getZ() {
|
||||||
|
return z;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMinimumPoint() {
|
||||||
|
return BlockVector3.at(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockVector3 getMaximumPoint() {
|
||||||
|
return BlockVector3.at(x, y, z);
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,6 @@ public class SetFilter implements Filter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void applyBlock(final FilterBlock block) {
|
public void applyBlock(final FilterBlock block) {
|
||||||
block.setState(state);
|
block.setBlock(state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import com.boydti.fawe.Fawe;
|
|||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.FaweCache;
|
||||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.Filter;
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IQueueExtent;
|
import com.boydti.fawe.beta.IQueueExtent;
|
||||||
import com.boydti.fawe.beta.Trimable;
|
import com.boydti.fawe.beta.Trimable;
|
||||||
@ -186,7 +185,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
|||||||
if (newChunk != null) {
|
if (newChunk != null) {
|
||||||
chunk = newChunk;
|
chunk = newChunk;
|
||||||
if (block == null) block = queue.initFilterBlock();
|
if (block == null) block = queue.initFilterBlock();
|
||||||
chunk.filter(newFilter, block, region, mbv1, mbv2);
|
chunk.filterBlocks(newFilter, block, region, mbv1, mbv2);
|
||||||
}
|
}
|
||||||
queue.submit(chunk);
|
queue.submit(chunk);
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
package com.boydti.fawe.beta.implementation;
|
package com.boydti.fawe.beta.implementation;
|
||||||
|
|
||||||
import com.boydti.fawe.beta.CharFilterBlock;
|
import com.boydti.fawe.beta.CharFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
|
|
||||||
public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent {
|
public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent {
|
||||||
@Override
|
@Override
|
||||||
public FilterBlock initFilterBlock() {
|
public ChunkFilterBlock initFilterBlock() {
|
||||||
return new CharFilterBlock(this);
|
return new CharFilterBlock(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public abstract class ChunkHolder implements IChunk, Supplier<IChunkGet> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void filter(final Filter filter, ChunkFilterBlock block, @Nullable Region region, @Nullable final MutableBlockVector3 min, @Nullable final MutableBlockVector3 max) {
|
public void filterBlocks(final Filter filter, ChunkFilterBlock block, @Nullable Region region, @Nullable final MutableBlockVector3 min, @Nullable final MutableBlockVector3 max) {
|
||||||
final IChunkGet get = getOrCreateGet();
|
final IChunkGet get = getOrCreateGet();
|
||||||
final IChunkSet set = getOrCreateSet();
|
final IChunkSet set = getOrCreateSet();
|
||||||
try {
|
try {
|
||||||
|
@ -1,10 +1,16 @@
|
|||||||
package com.boydti.fawe.beta.implementation.holder;
|
package com.boydti.fawe.beta.implementation.holder;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.Filter;
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.beta.FilterBlockMask;
|
import com.boydti.fawe.beta.FilterBlockMask;
|
||||||
import com.boydti.fawe.beta.Flood;
|
import com.boydti.fawe.beta.Flood;
|
||||||
import com.boydti.fawe.beta.IChunk;
|
import com.boydti.fawe.beta.IChunk;
|
||||||
import com.boydti.fawe.beta.IDelegateChunk;
|
import com.boydti.fawe.beta.IDelegateChunk;
|
||||||
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Implementation of IDelegateChunk
|
* Implementation of IDelegateChunk
|
||||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.command;
|
|||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweAPI;
|
import com.boydti.fawe.FaweAPI;
|
||||||
|
import com.boydti.fawe.beta.SingleFilterBlock;
|
||||||
import com.boydti.fawe.config.BBC;
|
import com.boydti.fawe.config.BBC;
|
||||||
import com.boydti.fawe.config.Commands;
|
import com.boydti.fawe.config.Commands;
|
||||||
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
import com.boydti.fawe.jnbt.anvil.HeightMapMCAGenerator;
|
||||||
@ -9,7 +10,6 @@ import com.boydti.fawe.object.FawePlayer;
|
|||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.RunnableVal;
|
import com.boydti.fawe.object.RunnableVal;
|
||||||
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
import com.boydti.fawe.object.clipboard.MultiClipboardHolder;
|
||||||
import com.boydti.fawe.object.pattern.PatternExtent;
|
|
||||||
import com.boydti.fawe.util.CleanTextureUtil;
|
import com.boydti.fawe.util.CleanTextureUtil;
|
||||||
import com.boydti.fawe.util.FilteredTextureUtil;
|
import com.boydti.fawe.util.FilteredTextureUtil;
|
||||||
import com.boydti.fawe.util.ImgurUtility;
|
import com.boydti.fawe.util.ImgurUtility;
|
||||||
@ -37,7 +37,6 @@ import com.sk89q.worldedit.extension.platform.Platform;
|
|||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.Vector3;
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
@ -70,7 +69,6 @@ import java.util.Date;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Consumer;
|
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||||
@ -419,9 +417,7 @@ public class CFICommands extends MethodCommands {
|
|||||||
}
|
}
|
||||||
default: {
|
default: {
|
||||||
blocks = new HashSet<>();
|
blocks = new HashSet<>();
|
||||||
BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
|
SingleFilterBlock extent = new SingleFilterBlock();
|
||||||
PatternExtent extent = new PatternExtent(pattern);
|
|
||||||
|
|
||||||
ParserContext parserContext = new ParserContext();
|
ParserContext parserContext = new ParserContext();
|
||||||
parserContext.setActor(player);
|
parserContext.setActor(player);
|
||||||
parserContext.setWorld(player.getWorld());
|
parserContext.setWorld(player.getWorld());
|
||||||
@ -432,9 +428,10 @@ public class CFICommands extends MethodCommands {
|
|||||||
TextureUtil tu = Fawe.get().getTextureUtil();
|
TextureUtil tu = Fawe.get().getTextureUtil();
|
||||||
for (int typeId : tu.getValidBlockIds()) {
|
for (int typeId : tu.getValidBlockIds()) {
|
||||||
BlockType type = BlockTypes.get(typeId);
|
BlockType type = BlockTypes.get(typeId);
|
||||||
BlockStateHolder block = type.getDefaultState();
|
extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
|
||||||
pattern.setBlock(block);
|
if (mask.test(extent)) {
|
||||||
if (mask.test(BlockVector3.ZERO)) blocks.add(type);
|
blocks.add(type);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -104,7 +104,7 @@ public class MCAWorld implements SimpleWorld {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return extent.getLazyBlock(position);
|
return extent.getBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -150,7 +150,7 @@ public class CavesGen extends GenBase {
|
|||||||
for (int local_z = i3; (!waterFound) && (local_z < i4); local_z++) {
|
for (int local_z = i3; (!waterFound) && (local_z < i4); local_z++) {
|
||||||
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--) {
|
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--) {
|
||||||
if (local_y < 255) {
|
if (local_y < 255) {
|
||||||
BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
|
BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||||
if (material.getBlockType() == BlockTypes.WATER) {
|
if (material.getBlockType() == BlockTypes.WATER) {
|
||||||
waterFound = true;
|
waterFound = true;
|
||||||
}
|
}
|
||||||
@ -174,8 +174,8 @@ public class CavesGen extends GenBase {
|
|||||||
for (int local_y = i2; local_y > i1; local_y--) {
|
for (int local_y = i2; local_y > i1; local_y--) {
|
||||||
double d11 = ((local_y - 1) + 0.5D - y) / d4;
|
double d11 = ((local_y - 1) + 0.5D - y) / d4;
|
||||||
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) {
|
if ((d11 > -0.7D) && (d9 * d9 + d11 * d11 + d10 * d10 < 1.0D)) {
|
||||||
BlockStateHolder material = chunk.getLazyBlock(bx + local_x, local_y, bz + local_z);
|
BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||||
BlockStateHolder materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z);
|
BlockStateHolder materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||||
BlockType blockType = material.getBlockType();
|
BlockType blockType = material.getBlockType();
|
||||||
switch (blockType.getInternalId()) {
|
switch (blockType.getInternalId()) {
|
||||||
case BlockID.MYCELIUM:
|
case BlockID.MYCELIUM:
|
||||||
@ -192,7 +192,7 @@ public class CavesGen extends GenBase {
|
|||||||
// If grass was just deleted, try to
|
// If grass was just deleted, try to
|
||||||
// move it down
|
// move it down
|
||||||
if (grassFound) {
|
if (grassFound) {
|
||||||
BlockStateHolder block = chunk.getLazyBlock(bx + local_x, local_y - 1, bz + local_z);
|
BlockStateHolder block = chunk.getBlock(bx + local_x, local_y - 1, bz + local_z);
|
||||||
if (block.getBlockType() == BlockTypes.DIRT) {
|
if (block.getBlockType() == BlockTypes.DIRT) {
|
||||||
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
|
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
|
||||||
}
|
}
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
package com.boydti.fawe.object;
|
package com.boydti.fawe.object;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.object.extent.ExtentHeightCacher;
|
import com.boydti.fawe.object.extent.ExtentHeightCacher;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
public class DataAnglePattern extends AbstractPattern {
|
public class DataAnglePattern extends AbstractPattern {
|
||||||
public final double FACTOR;
|
public final double FACTOR;
|
||||||
@ -24,7 +23,7 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
this.FACTOR = (1D / distance) * (1D / 255);
|
this.FACTOR = (1D / distance) * (1D / 255);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSlope(BlockStateHolder block, BlockVector3 vector) {
|
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
|
||||||
int x = vector.getBlockX();
|
int x = vector.getBlockX();
|
||||||
int y = vector.getBlockY();
|
int y = vector.getBlockY();
|
||||||
int z = vector.getBlockZ();
|
int z = vector.getBlockZ();
|
||||||
@ -32,7 +31,6 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
int slope;
|
int slope;
|
||||||
boolean aboveMin;
|
|
||||||
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7;
|
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z, y, 0, maxY)) * 7;
|
||||||
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7;
|
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - distance, y, 0, maxY)) * 7;
|
||||||
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5;
|
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + distance, z + distance, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - distance, z - distance, y, 0, maxY)) * 5;
|
||||||
@ -42,8 +40,8 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BlockStateHolder block = extent.getBlock(position);
|
BlockState block = extent.getBlock(position);
|
||||||
int slope = getSlope(block, position);
|
int slope = getSlope(block, position, extent);
|
||||||
if (slope == -1) return block.toBaseBlock();
|
if (slope == -1) return block.toBaseBlock();
|
||||||
int data = (Math.min(slope, 255)) >> 4;
|
int data = (Math.min(slope, 255)) >> 4;
|
||||||
return block.withPropertyId(data).toBaseBlock();
|
return block.withPropertyId(data).toBaseBlock();
|
||||||
@ -52,7 +50,7 @@ public class DataAnglePattern extends AbstractPattern {
|
|||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||||
BlockStateHolder block = extent.getBlock(getPosition);
|
BlockStateHolder block = extent.getBlock(getPosition);
|
||||||
int slope = getSlope(block, getPosition);
|
int slope = getSlope(block, getPosition, extent);
|
||||||
if (slope == -1) return false;
|
if (slope == -1) return false;
|
||||||
int data = (Math.min(slope, 255)) >> 4;
|
int data = (Math.min(slope, 255)) >> 4;
|
||||||
return extent.setBlock(setPosition, block.withPropertyId(data));
|
return extent.setBlock(setPosition, block.withPropertyId(data));
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.brush;
|
package com.boydti.fawe.object.brush;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.object.FaweQueue;
|
import com.boydti.fawe.object.FaweQueue;
|
||||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||||
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
import com.boydti.fawe.object.mask.AdjacentAnyMask;
|
||||||
@ -7,6 +8,7 @@ import com.boydti.fawe.object.mask.RadiusMask;
|
|||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.MaxChangedBlocksException;
|
import com.sk89q.worldedit.MaxChangedBlocksException;
|
||||||
import com.sk89q.worldedit.command.tool.brush.Brush;
|
import com.sk89q.worldedit.command.tool.brush.Brush;
|
||||||
|
import com.sk89q.worldedit.function.mask.BlockMask;
|
||||||
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
import com.sk89q.worldedit.function.mask.BlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
@ -34,7 +36,7 @@ public class LayerBrush implements Brush {
|
|||||||
@Override
|
@Override
|
||||||
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
|
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
|
||||||
final FaweQueue queue = editSession.getQueue();
|
final FaweQueue queue = editSession.getQueue();
|
||||||
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockTypeMask(editSession, BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
|
final AdjacentAnyMask adjacent = new AdjacentAnyMask(new BlockMask(editSession).add(BlockTypes.AIR, BlockTypes.CAVE_AIR, BlockTypes.VOID_AIR));
|
||||||
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
final SolidBlockMask solid = new SolidBlockMask(editSession);
|
||||||
final RadiusMask radius = new RadiusMask(0, (int) size);
|
final RadiusMask radius = new RadiusMask(0, (int) size);
|
||||||
visitor = new RecursiveVisitor(vector -> solid.test(vector) && radius.test(vector) && adjacent.test(vector), function -> true);
|
visitor = new RecursiveVisitor(vector -> solid.test(vector) && radius.test(vector) && adjacent.test(vector), function -> true);
|
||||||
@ -42,30 +44,32 @@ public class LayerBrush implements Brush {
|
|||||||
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
BlockVectorSet visited = visitor.getVisited();
|
BlockVectorSet visited = visitor.getVisited();
|
||||||
BlockStateHolder firstPattern = layers[0];
|
visitor = new RecursiveVisitor(new Mask() {
|
||||||
visitor = new RecursiveVisitor((Mask) pos -> {
|
@Override
|
||||||
int depth = visitor.getDepth() + 1;
|
public boolean test(BlockVector3 pos) {
|
||||||
if (depth > 1) {
|
int depth = visitor.getDepth() + 1;
|
||||||
boolean found = false;
|
if (depth > 1) {
|
||||||
int previous = layers[depth - 1].getInternalId();
|
boolean found = false;
|
||||||
int previous2 = layers[depth - 2].getInternalId();
|
int previous = layers[depth - 1].getInternalId();
|
||||||
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
int previous2 = layers[depth - 2].getInternalId();
|
||||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
||||||
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
||||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
|
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
||||||
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
|
mutable.setComponents(pos.getBlockX() + dir.getBlockX() * 2, pos.getBlockY() + dir.getBlockY() * 2, pos.getBlockZ() + dir.getBlockZ() * 2);
|
||||||
found = true;
|
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous2) {
|
||||||
break;
|
found = true;
|
||||||
} else {
|
break;
|
||||||
return false;
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!found) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (!found) {
|
return !adjacent.test(pos);
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return !adjacent.test(pos);
|
|
||||||
}, pos -> {
|
}, pos -> {
|
||||||
int depth = visitor.getDepth();
|
int depth = visitor.getDepth();
|
||||||
BlockStateHolder currentPattern = layers[depth];
|
BlockStateHolder currentPattern = layers[depth];
|
||||||
|
@ -79,7 +79,7 @@ public class EmptyClipboard implements Clipboard {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,17 +52,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 location) {
|
public BlockState getBlock(BlockVector3 location) {
|
||||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 location) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
return super.getBlock(x + dx, y + dy, z + dz);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
|
||||||
return super.getLazyBlock(x + dx, y + dy, z + dz);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -50,7 +50,7 @@ public class EmptyExtent implements Extent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,8 +112,6 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
|||||||
public <B extends BlockStateHolder<B>> boolean setBlock(final BlockVector3 location, final B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(final BlockVector3 location, final B block) throws WorldEditException {
|
||||||
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, final B block) throws WorldEditException {
|
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, final B block) throws WorldEditException {
|
||||||
@ -121,12 +119,12 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 location) {
|
public BlockState getBlock(BlockVector3 location) {
|
||||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
int combinedId4Data = queue.getCombinedId4Data(x, y, z, 0);
|
int combinedId4Data = queue.getCombinedId4Data(x, y, z, 0);
|
||||||
BlockType type = BlockTypes.getFromStateId(combinedId4Data);
|
BlockType type = BlockTypes.getFromStateId(combinedId4Data);
|
||||||
BlockState state = type.withStateId(combinedId4Data);
|
BlockState state = type.withStateId(combinedId4Data);
|
||||||
@ -157,11 +155,6 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
|||||||
return world.getEntities(region);
|
return world.getEntities(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(final BlockVector3 position) {
|
|
||||||
return this.getLazyBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
||||||
queue.setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
queue.setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
||||||
|
@ -66,7 +66,7 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
if(reason != null) {
|
if(reason != null) {
|
||||||
throw new FaweException(reason);
|
throw new FaweException(reason);
|
||||||
}else {
|
}else {
|
||||||
@ -74,6 +74,15 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BaseBlock getFullBlock(int x, int y, int z) {
|
||||||
|
if(reason != null) {
|
||||||
|
throw new FaweException(reason);
|
||||||
|
}else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
||||||
if(reason != null) {
|
if(reason != null) {
|
||||||
@ -101,15 +110,6 @@ public class NullExtent extends FaweRegionExtent {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
|
||||||
if(reason != null) {
|
|
||||||
throw new FaweException(reason);
|
|
||||||
}else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||||
if(reason != null) {
|
if(reason != null) {
|
||||||
|
@ -47,20 +47,15 @@ public class PositionTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return super.getLazyBlock(getPos(BlockVector3.at(x, y, z)));
|
return super.getBlock(getPos(BlockVector3.at(x, y, z)));
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return super.getLazyBlock(getPos(position));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return super.getBlock(getPos(position));
|
return super.getBlock(getPos(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return super.getFullBlock(getPos(position));
|
return super.getFullBlock(getPos(position));
|
||||||
|
@ -63,12 +63,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
if (!limit.MAX_CHECKS()) {
|
if (!limit.MAX_CHECKS()) {
|
||||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||||
return EditSession.nullBlock;
|
return EditSession.nullBlock;
|
||||||
} else {
|
} else {
|
||||||
return extent.getLazyBlock(x, y, z);
|
return extent.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -88,8 +88,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 location) {
|
public BlockState getBlock(BlockVector3 location) {
|
||||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -58,19 +58,11 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
if (position.getX() == x && position.getY() == y && position.getZ() == z) {
|
|
||||||
return block.toImmutableState();
|
|
||||||
}
|
|
||||||
return super.getLazyBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
|
||||||
if (this.x == x && this.y == y && this.z == z) {
|
if (this.x == x && this.y == y && this.z == z) {
|
||||||
return block.toImmutableState();
|
return block.toImmutableState();
|
||||||
}
|
}
|
||||||
return super.getLazyBlock(x, y, z);
|
return super.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.object.extent;
|
package com.boydti.fawe.object.extent;
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
|
import com.sk89q.worldedit.math.Vector3;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -14,7 +15,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
|
|
||||||
public class TransformExtent extends BlockTransformExtent {
|
public class TransformExtent extends BlockTransformExtent {
|
||||||
|
|
||||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
private final MutableVector3 mutable1 = new MutableVector3();
|
||||||
|
private final MutableBlockVector3 mutable2 = new MutableBlockVector3();
|
||||||
private BlockVector3 min;
|
private BlockVector3 min;
|
||||||
private int maxy;
|
private int maxy;
|
||||||
|
|
||||||
@ -53,56 +55,45 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = pos;
|
min = pos;
|
||||||
}
|
}
|
||||||
mutable.mutX(((pos.getX() - min.getX())));
|
mutable1.mutX(((pos.getX() - min.getX())));
|
||||||
mutable.mutY(((pos.getY() - min.getY())));
|
mutable1.mutY(((pos.getY() - min.getY())));
|
||||||
mutable.mutZ(((pos.getZ() - min.getZ())));
|
mutable1.mutZ(((pos.getZ() - min.getZ())));
|
||||||
MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
|
Vector3 tmp = getTransform().apply(mutable1);
|
||||||
tmp.mutX((tmp.getX() + min.getX()));
|
mutable2.mutX((tmp.getX() + min.getX()));
|
||||||
tmp.mutY((tmp.getY() + min.getY()));
|
mutable2.mutY((tmp.getY() + min.getY()));
|
||||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
||||||
return tmp.toBlockPoint();
|
return mutable2;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockVector3 getPos(int x, int y, int z) {
|
public BlockVector3 getPos(int x, int y, int z) {
|
||||||
if (min == null) {
|
if (min == null) {
|
||||||
min = BlockVector3.at(x, y, z);
|
min = BlockVector3.at(x, y, z);
|
||||||
}
|
}
|
||||||
mutable.mutX(((x - min.getX())));
|
mutable1.mutX(((x - min.getX())));
|
||||||
mutable.mutY(((y - min.getY())));
|
mutable1.mutY(((y - min.getY())));
|
||||||
mutable.mutZ(((z - min.getZ())));
|
mutable1.mutZ(((z - min.getZ())));
|
||||||
MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
|
Vector3 tmp = getTransform().apply(mutable1);
|
||||||
tmp.mutX((tmp.getX() + min.getX()));
|
mutable2.mutX((tmp.getX() + min.getX()));
|
||||||
tmp.mutY((tmp.getY() + min.getY()));
|
mutable2.mutY((tmp.getY() + min.getY()));
|
||||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
||||||
return tmp.toBlockPoint();
|
return tmp.toBlockPoint();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return transform(super.getLazyBlock(getPos(x, y, z)));
|
BlockVector3 p = getPos(x, y, z);
|
||||||
|
return transform(super.getBlock(p.getX(), p.getY(), p.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getLazyBlock(getPos(position)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getBlock(getPos(position)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return transform(super.getFullBlock(getPos(position)));
|
return transform(super.getFullBlock(getPos(position)));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
public BiomeType getBiome(int x, int z) {
|
||||||
mutable.mutX(position.getBlockX());
|
BlockVector3 p = getPos(x, 0, z);
|
||||||
mutable.mutZ(position.getBlockZ());
|
return super.getBiome(p.getX(), p.getZ());
|
||||||
mutable.mutY(0);
|
|
||||||
return super.getBiome(getPos(mutable).toBlockVector2());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -117,10 +108,8 @@ public class TransformExtent extends BlockTransformExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||||
mutable.mutX(position.getBlockX());
|
BlockVector3 p = getPos(x, y, z);
|
||||||
mutable.mutZ(position.getBlockZ());
|
return super.setBiome(p.getX(), p.getY(), p.getZ(), biome);
|
||||||
mutable.mutY(0);
|
|
||||||
return super.setBiome(getPos(mutable).toBlockVector2(), biome);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.function.mask;
|
package com.boydti.fawe.object.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.function.mask.AbstractMask;
|
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.mask.Mask2D;
|
import com.sk89q.worldedit.function.mask.Mask2D;
|
||||||
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.boydti.fawe.object.mask;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.function.mask.AbstractMask;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
|
public class AdjacentAnyMask2 extends AbstractMask {
|
||||||
|
@Override
|
||||||
|
public boolean test(BlockVector3 vector) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -19,9 +19,9 @@ public class DataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
if (data != -1) {
|
if (data != -1) {
|
||||||
return extent.getLazyBlock(vector).getInternalPropertiesId() == data;
|
return extent.getBlock(vector).getInternalPropertiesId() == data;
|
||||||
} else {
|
} else {
|
||||||
data = extent.getLazyBlock(vector).getInternalPropertiesId();
|
data = extent.getBlock(vector).getInternalPropertiesId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
if (combined != -1) {
|
if (combined != -1) {
|
||||||
return extent.getLazyBlock(vector).getInternalId() == combined;
|
return extent.getBlock(vector).getInternalId() == combined;
|
||||||
} else {
|
} else {
|
||||||
combined = extent.getLazyBlock(vector).getInternalId();
|
combined = extent.getBlock(vector).getInternalId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,9 +19,9 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
|||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
Extent extent = getExtent();
|
Extent extent = getExtent();
|
||||||
if (id != -1) {
|
if (id != -1) {
|
||||||
return extent.getLazyBlock(vector).getInternalBlockTypeId() == id;
|
return extent.getBlock(vector).getInternalBlockTypeId() == id;
|
||||||
} else {
|
} else {
|
||||||
id = extent.getLazyBlock(vector).getInternalBlockTypeId();
|
id = extent.getBlock(vector).getInternalBlockTypeId();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
public class SurfaceMask extends AdjacentAnyMask {
|
public class SurfaceMask extends AdjacentAnyMask {
|
||||||
private final transient Extent extent;
|
|
||||||
|
|
||||||
public SurfaceMask(Extent extent) {
|
public SurfaceMask(Extent extent) {
|
||||||
super(getMask(extent));
|
super(getMask(extent));
|
||||||
this.extent = extent;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mask getMask(Extent extent) {
|
public static Mask getMask(Extent extent) {
|
||||||
|
@ -2,6 +2,8 @@ package com.boydti.fawe.object.pattern;
|
|||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
@ -1,11 +1,8 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.FaweCache;
|
|
||||||
import com.boydti.fawe.beta.FilterBlock;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.object.DataAnglePattern;
|
import com.boydti.fawe.object.DataAnglePattern;
|
||||||
import com.boydti.fawe.util.TextureHolder;
|
import com.boydti.fawe.util.TextureHolder;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -14,14 +11,12 @@ import com.sk89q.worldedit.math.BlockVector3;
|
|||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class AngleColorPattern extends DataAnglePattern {
|
public class AngleColorPattern extends DataAnglePattern {
|
||||||
protected transient TextureUtil util;
|
protected transient TextureHolder holder;
|
||||||
|
|
||||||
public AngleColorPattern(Extent extent, TextureHolder holder, int distance) {
|
public AngleColorPattern(Extent extent, TextureHolder holder, int distance) {
|
||||||
super(extent, distance);
|
super(extent, distance);
|
||||||
this.util = holder.getTextureUtil();
|
this.holder = holder.getTextureUtil();
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor(int color, int slope) {
|
public int getColor(int color, int slope) {
|
||||||
@ -33,33 +28,20 @@ public class AngleColorPattern extends DataAnglePattern {
|
|||||||
return (((color >> 24) & 0xFF) << 24) + (newRed << 16) + (newGreen << 8) + (newBlue << 0);
|
return (((color >> 24) & 0xFF) << 24) + (newRed << 16) + (newGreen << 8) + (newBlue << 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void apply(FilterBlock block) {
|
|
||||||
BlockState state = block.getState();
|
|
||||||
int slope = getSlope(state, block);
|
|
||||||
if (slope == -1) return;
|
|
||||||
int color = util.getColor(state.getBlockType());
|
|
||||||
if (color == 0) return;
|
|
||||||
int newColor = getColor(color, slope);
|
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
|
||||||
if (newBlock == null) return;
|
|
||||||
newBlock.apply(block);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BaseBlock block = extent.getFullBlock(position);
|
BaseBlock block = extent.getFullBlock(position);
|
||||||
int slope = getSlope(block, position);
|
int slope = getSlope(block, position, extent);
|
||||||
if (slope == -1) return block;
|
if (slope == -1) return block;
|
||||||
int color = util.getColor(block.getBlockType());
|
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||||
if (color == 0) return block;
|
if (color == 0) return block;
|
||||||
int newColor = getColor(color, slope);
|
int newColor = getColor(color, slope);
|
||||||
return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getSlope(BlockStateHolder block, BlockVector3 vector) {
|
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
|
||||||
int slope = super.getSlope(block, vector);
|
int slope = super.getSlope(block, vector, extent);
|
||||||
if (slope != -1) {
|
if (slope != -1) {
|
||||||
int x = vector.getBlockX();
|
int x = vector.getBlockX();
|
||||||
int y = vector.getBlockY();
|
int y = vector.getBlockY();
|
||||||
@ -76,15 +58,15 @@ public class AngleColorPattern extends DataAnglePattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockStateHolder block = extent.getBlock(getPosition);
|
BlockStateHolder block = get.getBlock(extent);
|
||||||
int slope = getSlope(block, getPosition);
|
int slope = getSlope(block, get, extent);
|
||||||
if (slope == -1) return false;
|
if (slope == -1) return false;
|
||||||
int color = util.getColor(block.getBlockType());
|
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||||
if (color == 0) return false;
|
if (color == 0) return false;
|
||||||
int newColor = getColor(color, slope);
|
int newColor = getColor(color, slope);
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
BlockType newBlock = holder.getTextureUtil().getNearestBlock(newColor);
|
||||||
if (newBlock == null) return false;
|
if (newBlock == null) return false;
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newBlock.getDefaultState());
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,19 +1,14 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.util.TextureHolder;
|
import com.boydti.fawe.util.TextureHolder;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class AverageColorPattern extends AbstractExtentPattern {
|
public class AverageColorPattern extends AbstractExtentPattern {
|
||||||
private transient TextureHolder holder;
|
private transient TextureHolder holder;
|
||||||
@ -35,19 +30,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType blockType = extent.getBlockType(getPosition);
|
BlockType blockType = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int currentColor = util.getColor(blockType);
|
int currentColor = util.getColor(blockType);
|
||||||
if (currentColor == 0) return false;
|
if (currentColor == 0) return false;
|
||||||
int newColor = util.averageColor(currentColor, color);
|
int newColor = util.averageColor(currentColor, color);
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
BlockType newBlock = util.getNearestBlock(newColor);
|
||||||
if (newBlock == blockType) return false;
|
if (newBlock == blockType) return false;
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newBlock.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -10,7 +11,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class BiomePattern extends ExistingPattern {
|
public class BiomePattern extends ExistingPattern {
|
||||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
|
||||||
private final BiomeType biome;
|
private final BiomeType biome;
|
||||||
|
|
||||||
public BiomePattern(Extent extent, BiomeType biome) {
|
public BiomePattern(Extent extent, BiomeType biome) {
|
||||||
@ -24,8 +24,8 @@ public class BiomePattern extends ExistingPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
return extent.setBiome(set.getBlockX(), set.getBlockY(), set.getBlockZ(), biome);
|
return set.setBiome(extent, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class BiomePatternException extends RuntimeException {
|
public class BiomePatternException extends RuntimeException {
|
||||||
@ -45,9 +45,4 @@ public class BiomePattern extends ExistingPattern {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
mutable = new MutableBlockVector2();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.object.FawePlayer;
|
import com.boydti.fawe.object.FawePlayer;
|
||||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||||
import com.boydti.fawe.util.FaweTimer;
|
import com.boydti.fawe.util.FaweTimer;
|
||||||
@ -17,17 +18,18 @@ import java.io.IOException;
|
|||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class BufferedPattern extends AbstractPattern implements ResettablePattern {
|
public class BufferedPattern extends AbstractPattern implements ResettablePattern {
|
||||||
protected transient LocalBlockVectorSet set = new LocalBlockVectorSet();
|
protected final LocalBlockVectorSet set = new LocalBlockVectorSet();
|
||||||
protected transient FaweTimer timer;
|
protected final FaweTimer timer;
|
||||||
protected transient long[] actionTime;
|
protected final long[] actionTime;
|
||||||
|
|
||||||
protected final Pattern pattern;
|
protected final Pattern pattern;
|
||||||
protected final UUID uuid;
|
protected final UUID uuid;
|
||||||
|
|
||||||
public BufferedPattern(FawePlayer fp, Pattern parent) {
|
public BufferedPattern(FawePlayer fp, Pattern parent) {
|
||||||
this.uuid = fp.getUUID();
|
this.uuid = fp.getUUID();
|
||||||
this.actionTime = fp.getMeta("lastActionTime");
|
long[] tmp = fp.getMeta("lastActionTime");
|
||||||
if (actionTime == null) fp.setMeta("lastActionTime", actionTime = new long[2]);
|
if (tmp == null) fp.setMeta("lastActionTime", tmp = new long[2]);
|
||||||
|
actionTime = tmp;
|
||||||
this.pattern = parent;
|
this.pattern = parent;
|
||||||
this.timer = Fawe.get().getTimer();
|
this.timer = Fawe.get().getTimer();
|
||||||
}
|
}
|
||||||
@ -38,16 +40,12 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
long now = timer.getTick();
|
actionTime[1] = timer.getTick();
|
||||||
try {
|
if (!set(get)) {
|
||||||
if (!set(setPosition)) {
|
return false;
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return pattern.apply(extent, setPosition, getPosition);
|
|
||||||
} catch (UnsupportedOperationException ignore) {
|
|
||||||
}
|
}
|
||||||
return false;
|
return pattern.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean set(BlockVector3 pos) {
|
public boolean set(BlockVector3 pos) {
|
||||||
@ -63,17 +61,4 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
|
|||||||
actionTime[1] = actionTime[0];
|
actionTime[1] = actionTime[0];
|
||||||
actionTime[0] = now;
|
actionTime[0] = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
set = new LocalBlockVectorSet();
|
|
||||||
timer = Fawe.get().getTimer();
|
|
||||||
FawePlayer fp = Fawe.get().getCachedPlayer(uuid);
|
|
||||||
if (fp != null) {
|
|
||||||
this.actionTime = fp.getMeta("lastActionTime");
|
|
||||||
if (actionTime == null) fp.setMeta("lastActionTime", actionTime = new long[2]);
|
|
||||||
} else {
|
|
||||||
actionTime = new long[2];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
@ -25,6 +25,24 @@ public class DataPattern extends AbstractExtentPattern {
|
|||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BaseBlock oldBlock = getExtent().getFullBlock(position);
|
BaseBlock oldBlock = getExtent().getFullBlock(position);
|
||||||
BaseBlock newBlock = pattern.apply(position);
|
BaseBlock newBlock = pattern.apply(position);
|
||||||
return oldBlock.withPropertyId(newBlock.getInternalPropertiesId()).toBaseBlock();
|
return oldBlock.toBlockState().withProperties(newBlock.toBlockState()).toBaseBlock(newBlock.getNbtData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
|
BaseBlock oldBlock = get.getFullBlock(extent);
|
||||||
|
BaseBlock newBlock = pattern.apply(get);
|
||||||
|
|
||||||
|
BlockState oldState = oldBlock.toBlockState();
|
||||||
|
BlockState newState = oldState.withProperties(newBlock.toBlockState());
|
||||||
|
if (newState != oldState) {
|
||||||
|
if (oldBlock.hasNbtData()) {
|
||||||
|
set.setFullBlock(extent, newState.toBaseBlock(oldBlock.getNbtData()));
|
||||||
|
} else {
|
||||||
|
set.setBlock(extent, newState);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,16 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
|
||||||
import com.boydti.fawe.util.TextureHolder;
|
import com.boydti.fawe.util.TextureHolder;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class DesaturatePattern extends AbstractPattern {
|
public class DesaturatePattern extends AbstractPattern {
|
||||||
private transient TextureHolder holder;
|
private final TextureHolder holder;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final double value;
|
private final double value;
|
||||||
|
|
||||||
@ -29,7 +24,11 @@ public class DesaturatePattern extends AbstractPattern {
|
|||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
BlockType block = extent.getBlockType(position);
|
BlockType block = extent.getBlockType(position);
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int color = util.getColor(block);
|
int color = getColor(util.getColor(block));
|
||||||
|
return util.getNearestBlock(color).getDefaultState().toBaseBlock();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getColor(int color) {
|
||||||
int r = (color >> 16) & 0xFF;
|
int r = (color >> 16) & 0xFF;
|
||||||
int g = (color >> 8) & 0xFF;
|
int g = (color >> 8) & 0xFF;
|
||||||
int b = (color >> 0) & 0xFF;
|
int b = (color >> 0) & 0xFF;
|
||||||
@ -39,35 +38,22 @@ public class DesaturatePattern extends AbstractPattern {
|
|||||||
int green = (int) (g + value * (l - g));
|
int green = (int) (g + value * (l - g));
|
||||||
int blue = (int) (b + value * (l - b));
|
int blue = (int) (b + value * (l - b));
|
||||||
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
||||||
return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
return newColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType block = extent.getBlockType(getPosition);
|
BlockType type = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int color = util.getColor(block);
|
int color = util.getColor(type);
|
||||||
int r = (color >> 16) & 0xFF;
|
int newColor = getColor(color);
|
||||||
int g = (color >> 8) & 0xFF;
|
|
||||||
int b = (color >> 0) & 0xFF;
|
|
||||||
int alpha = (color >> 24) & 0xFF;
|
|
||||||
double l = 0.3f * r + 0.6f * g + 0.1f * b;
|
|
||||||
int red = (int) (r + value * (l - r));
|
|
||||||
int green = (int) (g + value * (l - g));
|
|
||||||
int blue = (int) (b + value * (l - b));
|
|
||||||
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
|
||||||
if (newColor == color) {
|
if (newColor == color) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
BlockType newBlock = util.getNextNearestBlock(newColor);
|
BlockType newType = util.getNextNearestBlock(newColor);
|
||||||
if (block.equals(newBlock)) {
|
if (type.equals(newType)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newType.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,12 +1,10 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
|
||||||
|
|
||||||
public class ExistingPattern extends AbstractExtentPattern {
|
public class ExistingPattern extends AbstractExtentPattern {
|
||||||
public ExistingPattern(Extent extent) {
|
public ExistingPattern(Extent extent) {
|
||||||
@ -19,10 +17,10 @@ public class ExistingPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
if (set.equals(get)) {
|
if (set == get || set.equals(get)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return extent.setBlock(set, extent.getBlock(get));
|
return set.setFullBlock(extent, get.getFullBlock(extent));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -23,9 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
|||||||
* greater than {@code 0}.</p>
|
* greater than {@code 0}.</p>
|
||||||
*/
|
*/
|
||||||
public class ExpressionPattern extends AbstractPattern {
|
public class ExpressionPattern extends AbstractPattern {
|
||||||
|
private final Expression expression;
|
||||||
public String input;
|
|
||||||
private transient Expression expression;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
@ -35,7 +34,6 @@ public class ExpressionPattern extends AbstractPattern {
|
|||||||
*/
|
*/
|
||||||
public ExpressionPattern(String input) throws ExpressionException {
|
public ExpressionPattern(String input) throws ExpressionException {
|
||||||
checkNotNull(input);
|
checkNotNull(input);
|
||||||
this.input = input;
|
|
||||||
this.expression = Expression.compile(input, "x", "y", "z");
|
this.expression = Expression.compile(input, "x", "y", "z");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,13 +63,4 @@ public class ExpressionPattern extends AbstractPattern {
|
|||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
try {
|
|
||||||
this.expression = Expression.compile(input, "x", "y", "z");
|
|
||||||
} catch (ExpressionException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -36,9 +36,8 @@ public class FullClipboardPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
Region region = clipboard.getRegion();
|
ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, set);
|
||||||
ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, setPosition);
|
|
||||||
copy.setSourceMask(new ExistingBlockMask(clipboard));
|
copy.setSourceMask(new ExistingBlockMask(clipboard));
|
||||||
Operations.completeBlindly(copy);
|
Operations.completeBlindly(copy);
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -27,11 +28,11 @@ public class Linear2DBlockPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
int index = (get.getBlockX() + get.getBlockZ()) % patternsArray.length;
|
int index = (get.getBlockX() + get.getBlockZ()) % patternsArray.length;
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index += patternsArray.length;
|
index += patternsArray.length;
|
||||||
}
|
}
|
||||||
return patternsArray[index].apply(extent, set, get);
|
return patternsArray[index].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -27,11 +28,11 @@ public class Linear3DBlockPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
int index = (get.getBlockX() + get.getBlockY() + get.getBlockZ()) % patternsArray.length;
|
int index = (get.getBlockX() + get.getBlockY() + get.getBlockZ()) % patternsArray.length;
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
index += patternsArray.length;
|
index += patternsArray.length;
|
||||||
}
|
}
|
||||||
return patternsArray[index].apply(extent, set, get);
|
return patternsArray[index].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,11 @@ public class LinearBlockPattern extends AbstractPattern implements ResettablePat
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
if (index == patternsArray.length) {
|
if (index == patternsArray.length) {
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
return patternsArray[index++].apply(extent, set, get);
|
return patternsArray[index++].apply(extent, get, set);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
|
import com.boydti.fawe.beta.SingleFilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -12,32 +14,30 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|||||||
|
|
||||||
public class MaskedPattern extends AbstractPattern {
|
public class MaskedPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final PatternExtent patternExtent;
|
private final Pattern primary;
|
||||||
private final Pattern secondaryPattern;
|
private final Pattern secondary;
|
||||||
private Mask mask;
|
private Mask mask;
|
||||||
|
|
||||||
public MaskedPattern(Mask mask, PatternExtent primary, Pattern secondary) {
|
public MaskedPattern(Mask mask, Pattern primary, Pattern secondary) {
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
this.patternExtent = primary;
|
this.primary = primary;
|
||||||
this.secondaryPattern = secondary;
|
this.secondary = secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
patternExtent.setTarget(position);
|
|
||||||
if (mask.test(position)) {
|
if (mask.test(position)) {
|
||||||
return patternExtent.getAndResetTarget().toBaseBlock();
|
return primary.apply(position);
|
||||||
}
|
}
|
||||||
return secondaryPattern.apply(position);
|
return secondary.apply(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
patternExtent.setTarget(get);
|
|
||||||
if (mask.test(get)) {
|
if (mask.test(get)) {
|
||||||
return patternExtent.getAndResetTarget(extent, set, get);
|
return primary.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
return secondaryPattern.apply(extent, set, get);
|
return secondary.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -15,7 +17,7 @@ import java.io.IOException;
|
|||||||
public class NoXPattern extends AbstractPattern {
|
public class NoXPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public NoXPattern(Pattern pattern) {
|
public NoXPattern(Pattern pattern) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
@ -23,21 +25,15 @@ public class NoXPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 pos) {
|
public BaseBlock apply(BlockVector3 pos) {
|
||||||
// mutable.mutY((pos.getY()));
|
mutable.mutY((pos.getY()));
|
||||||
// mutable.mutZ((pos.getZ()));
|
mutable.mutZ((pos.getZ()));
|
||||||
// return pattern.apply(mutable);
|
return pattern.apply(mutable);
|
||||||
return pattern.apply(pos);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
// mutable.mutY((get.getY()));
|
mutable.mutY((get.getY()));
|
||||||
// mutable.mutZ((get.getZ()));
|
mutable.mutZ((get.getZ()));
|
||||||
return pattern.apply(extent, set, get);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
// mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -15,29 +17,23 @@ import java.io.IOException;
|
|||||||
public class NoYPattern extends AbstractPattern {
|
public class NoYPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
|
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public NoYPattern(Pattern pattern) {
|
public NoYPattern(Pattern pattern) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 pos) {
|
public BaseBlock apply(BlockVector3 pos) {
|
||||||
// mutable.mutX((pos.getX()));
|
mutable.mutX((pos.getX()));
|
||||||
// mutable.mutZ((pos.getZ()));
|
mutable.mutZ((pos.getZ()));
|
||||||
return pattern.apply(pos);
|
return pattern.apply(mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
// mutable.mutX((get.getX()));
|
mutable.mutX((get.getX()));
|
||||||
// mutable.mutZ((get.getZ()));
|
mutable.mutZ((get.getZ()));
|
||||||
return pattern.apply(extent, set, get);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
// mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -20,24 +22,19 @@ public class NoZPattern extends AbstractPattern {
|
|||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
}
|
}
|
||||||
|
|
||||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 pos) {
|
public BaseBlock apply(BlockVector3 pos) {
|
||||||
// mutable.mutX((pos.getX()));
|
mutable.mutX((pos.getX()));
|
||||||
// mutable.mutY((pos.getY()));
|
mutable.mutY((pos.getY()));
|
||||||
return pattern.apply(pos);
|
return pattern.apply(mutable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
// mutable.mutX((get.getX()));
|
mutable.mutX((get.getX()));
|
||||||
// mutable.mutY((get.getY()));
|
mutable.mutY((get.getY()));
|
||||||
return pattern.apply(extent, set, get);
|
return pattern.apply(extent, mutable, set);
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
// mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
@ -15,7 +16,7 @@ import java.io.IOException;
|
|||||||
public class OffsetPattern extends AbstractPattern {
|
public class OffsetPattern extends AbstractPattern {
|
||||||
|
|
||||||
private final int dx, dy, dz;
|
private final int dx, dy, dz;
|
||||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
|
|
||||||
public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
|
public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
|
||||||
@ -27,24 +28,17 @@ public class OffsetPattern extends AbstractPattern {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
public BaseBlock apply(BlockVector3 position) {
|
||||||
// mutable.mutX((position.getX() + dx));
|
mutable.mutX((position.getX() + dx));
|
||||||
// mutable.mutY((position.getY() + dy));
|
mutable.mutY((position.getY() + dy));
|
||||||
// mutable.mutZ((position.getZ() + dz));
|
mutable.mutZ((position.getZ() + dz));
|
||||||
// return pattern.apply(mutable);
|
return pattern.apply(mutable);
|
||||||
return pattern.apply(BlockVector3.at(position.getX() + dx, position.getY() + dy, position.getZ() + dz));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
// mutable.mutX((get.getX() + dx));
|
mutable.mutX((get.getX() + dx));
|
||||||
// mutable.mutY((get.getY() + dy));
|
mutable.mutY((get.getY() + dy));
|
||||||
// mutable.mutZ((get.getZ() + dz));
|
mutable.mutZ((get.getZ() + dz));
|
||||||
// return pattern.apply(extent, set, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
return pattern.apply(extent, set, BlockVector3.at(get.getX() + dx, get.getY() + dy, get.getZ() + dz));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
// mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,134 +0,0 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.entity.BaseEntity;
|
|
||||||
import com.sk89q.worldedit.entity.Entity;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.function.operation.Operation;
|
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.regions.Region;
|
|
||||||
import com.sk89q.worldedit.util.Location;
|
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
public class PatternExtent extends AbstractPattern implements Extent {
|
|
||||||
private final Pattern pattern;
|
|
||||||
private transient BlockStateHolder block;
|
|
||||||
private transient BlockVector3 target = BlockVector3.at(0, 0, 0);
|
|
||||||
|
|
||||||
public PatternExtent(Pattern pattern) {
|
|
||||||
this.pattern = pattern;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
target = BlockVector3.at(0, 0, 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector3 getMinimumPoint() {
|
|
||||||
return BlockVector3.at(Integer.MIN_VALUE, 0, Integer.MIN_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockVector3 getMaximumPoint() {
|
|
||||||
return BlockVector3.at(Integer.MAX_VALUE, 255, Integer.MAX_VALUE);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities(Region region) {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<? extends Entity> getEntities() {
|
|
||||||
return new ArrayList<>();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Entity createEntity(Location location, BaseEntity entity) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
|
||||||
BlockStateHolder tmp = pattern.apply(position);
|
|
||||||
if (position == target || (position.getX() == target.getX() && position.getY() == target.getY() && position.getZ() == target.getZ())) {
|
|
||||||
block = tmp;
|
|
||||||
} else {
|
|
||||||
block = null;
|
|
||||||
}
|
|
||||||
return (BlockState) tmp;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setTarget(BlockVector3 vector) {
|
|
||||||
this.target = vector;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getAndResetTarget(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
|
||||||
BlockStateHolder result = block;
|
|
||||||
if (result != null) {
|
|
||||||
block = null;
|
|
||||||
return extent.setBlock(set, result);
|
|
||||||
} else {
|
|
||||||
return pattern.apply(extent, set, target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockStateHolder getAndResetTarget() {
|
|
||||||
BlockStateHolder result = block;
|
|
||||||
if (result != null) {
|
|
||||||
block = null;
|
|
||||||
return result;
|
|
||||||
} else {
|
|
||||||
return pattern.apply(target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position).toBaseBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BiomeType getBiome(BlockVector2 position) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBlock(BlockVector3 position, BlockStateHolder block) throws WorldEditException {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Operation commit() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public BaseBlock apply(BlockVector3 position) {
|
|
||||||
return pattern.apply(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
|
||||||
return pattern.apply(extent, set, get);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||||
import com.boydti.fawe.util.MathMan;
|
import com.boydti.fawe.util.MathMan;
|
||||||
import com.boydti.fawe.util.StringMan;
|
import com.boydti.fawe.util.StringMan;
|
||||||
@ -14,7 +15,6 @@ import com.sk89q.worldedit.registry.state.Property;
|
|||||||
import com.sk89q.worldedit.registry.state.PropertyKey;
|
import com.sk89q.worldedit.registry.state.PropertyKey;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
@ -211,11 +211,11 @@ public class PropertyPattern extends AbstractExtentPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BaseBlock block = getExtent().getFullBlock(get);
|
int ordinal = get.getOrdinal(extent);
|
||||||
block = apply(block, null);
|
int newOrdinal = transformed[ordinal];
|
||||||
if (block != null) {
|
if (newOrdinal != ordinal) {
|
||||||
return extent.setBlock(set, block);
|
set.setOrdinal(extent, newOrdinal);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
ClipboardHolder holder = clipboards.get(PseudoRandom.random.random(clipboards.size()));
|
||||||
AffineTransform transform = new AffineTransform();
|
AffineTransform transform = new AffineTransform();
|
||||||
if (randomRotate) {
|
if (randomRotate) {
|
||||||
@ -55,9 +55,9 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
|||||||
Schematic schematic = new Schematic(clipboard);
|
Schematic schematic = new Schematic(clipboard);
|
||||||
Transform newTransform = holder.getTransform();
|
Transform newTransform = holder.getTransform();
|
||||||
if (newTransform.isIdentity()) {
|
if (newTransform.isIdentity()) {
|
||||||
schematic.paste(extent, setPosition, false);
|
schematic.paste(extent, set, false);
|
||||||
} else {
|
} else {
|
||||||
schematic.paste(extent, setPosition, false, newTransform);
|
schematic.paste(extent, set, false, newTransform);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -40,19 +41,10 @@ public class RandomOffsetPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
|
mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
|
||||||
mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
|
mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
|
||||||
mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
|
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
|
||||||
return pattern.apply(extent, set, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
this.dx2 = dx * 2 + 1;
|
|
||||||
this.dy2 = dy * 2 + 1;
|
|
||||||
this.dz2 = dz * 2 + 1;
|
|
||||||
this.r = new SplittableRandom();
|
|
||||||
this.mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -13,8 +14,8 @@ import java.io.IOException;
|
|||||||
public class RelativePattern extends AbstractPattern implements ResettablePattern {
|
public class RelativePattern extends AbstractPattern implements ResettablePattern {
|
||||||
|
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
private transient BlockVector3 origin;
|
private BlockVector3 origin;
|
||||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||||
|
|
||||||
public RelativePattern(Pattern pattern) {
|
public RelativePattern(Pattern pattern) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
@ -32,19 +33,14 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
if (origin == null) {
|
if (origin == null) {
|
||||||
origin = get;
|
origin = set;
|
||||||
}
|
}
|
||||||
mutable.mutX((get.getX() - origin.getX()));
|
mutable.mutX((set.getX() - origin.getX()));
|
||||||
mutable.mutY((get.getY() - origin.getY()));
|
mutable.mutY((set.getY() - origin.getY()));
|
||||||
mutable.mutZ((get.getZ() - origin.getZ()));
|
mutable.mutZ((set.getZ() - origin.getZ()));
|
||||||
return pattern.apply(extent, set, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
mutable = new MutableBlockVector3();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,22 +1,19 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.util.TextureHolder;
|
import com.boydti.fawe.util.TextureHolder;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public class SaturatePattern extends AbstractPattern {
|
public class SaturatePattern extends AbstractPattern {
|
||||||
private transient TextureHolder holder;
|
private final TextureHolder holder;
|
||||||
private final int color;
|
private final int color;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
|
|
||||||
@ -37,19 +34,14 @@ public class SaturatePattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
BlockType block = extent.getBlockType(getPosition);
|
BlockType block = get.getBlock(extent).getBlockType();
|
||||||
TextureUtil util = holder.getTextureUtil();
|
TextureUtil util = holder.getTextureUtil();
|
||||||
int currentColor = util.getColor(block);
|
int currentColor = util.getColor(block);
|
||||||
if (currentColor == 0) return false;
|
if (currentColor == 0) return false;
|
||||||
int newColor = util.multiplyColor(currentColor, color);
|
int newColor = util.multiplyColor(currentColor, color);
|
||||||
BlockType newBlock = util.getNearestBlock(newColor);
|
BlockType newBlock = util.getNearestBlock(newColor);
|
||||||
if (newBlock.equals(block)) return false;
|
if (newBlock.equals(block)) return false;
|
||||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
return set.setBlock(extent, newBlock.getDefaultState());
|
||||||
}
|
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,22 +1,19 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.boydti.fawe.util.TextureUtil;
|
import com.boydti.fawe.util.TextureUtil;
|
||||||
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
public class ShadePattern extends AbstractPattern {
|
public class ShadePattern extends AbstractPattern {
|
||||||
private transient TextureUtil util;
|
private final TextureUtil util;
|
||||||
private final Extent extent;
|
private final Extent extent;
|
||||||
private final boolean darken;
|
private final boolean darken;
|
||||||
|
|
||||||
@ -33,8 +30,13 @@ public class ShadePattern extends AbstractPattern {
|
|||||||
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
@Override
|
||||||
stream.defaultReadObject();
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
util = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
BlockType type = get.getBlock(extent).getBlockType();
|
||||||
|
BlockType newType = (darken ? util.getDarkerBlock(type) : util.getLighterBlock(type));
|
||||||
|
if (type != newType) {
|
||||||
|
return set.setBlock(extent, newType.getDefaultState());
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEditException;
|
import com.sk89q.worldedit.WorldEditException;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -9,6 +10,8 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.math.MutableBlockVector3;
|
import com.sk89q.worldedit.math.MutableBlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.SplittableRandom;
|
import java.util.SplittableRandom;
|
||||||
@ -17,25 +20,27 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
|||||||
private final int dx, dy, dz;
|
private final int dx, dy, dz;
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
|
|
||||||
private transient int dx2, dy2, dz2;
|
private final int dx2, dy2, dz2;
|
||||||
private transient MutableBlockVector3 mutable;
|
private final MutableBlockVector3 mutable;
|
||||||
private transient boolean[] solid;
|
|
||||||
private SplittableRandom r;
|
private SplittableRandom r;
|
||||||
|
|
||||||
|
public static boolean[] getTypes() {
|
||||||
|
boolean[] types = new boolean[BlockTypes.size()];
|
||||||
|
for (BlockType type : BlockTypes.values) {
|
||||||
|
types[type.getInternalId()] = type.getMaterial().isSolid();
|
||||||
|
}
|
||||||
|
return types;
|
||||||
|
}
|
||||||
|
|
||||||
public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
|
public SolidRandomOffsetPattern(Pattern pattern, int dx, int dy, int dz) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.dx = dx;
|
this.dx = dx;
|
||||||
this.dy = dy;
|
this.dy = dy;
|
||||||
this.dz = dz;
|
this.dz = dz;
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
this.dx2 = dx * 2 + 1;
|
this.dx2 = dx * 2 + 1;
|
||||||
this.dy2 = dy * 2 + 1;
|
this.dy2 = dy * 2 + 1;
|
||||||
this.dz2 = dz * 2 + 1;
|
this.dz2 = dz * 2 + 1;
|
||||||
solid = SolidBlockMask.getTypes();
|
|
||||||
this.r = new SplittableRandom();
|
this.r = new SplittableRandom();
|
||||||
this.mutable = new MutableBlockVector3();
|
this.mutable = new MutableBlockVector3();
|
||||||
}
|
}
|
||||||
@ -46,7 +51,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
|||||||
mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
|
mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
|
||||||
mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
|
mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
|
||||||
BaseBlock block = pattern.apply(mutable);
|
BaseBlock block = pattern.apply(mutable);
|
||||||
if (solid[block.getInternalBlockTypeId()]) {
|
if (block.getMaterial().isSolid()) {
|
||||||
return block;
|
return block;
|
||||||
} else {
|
} else {
|
||||||
return pattern.apply(position);
|
return pattern.apply(position);
|
||||||
@ -54,20 +59,15 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||||
mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
|
mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
|
||||||
mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
|
mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
|
||||||
mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
|
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
|
||||||
BlockStateHolder block = pattern.apply(mutable);
|
BlockStateHolder block = pattern.apply(mutable);
|
||||||
if (solid[block.getInternalBlockTypeId()]) {
|
if (block.getMaterial().isSolid()) {
|
||||||
return pattern.apply(extent, set, mutable);
|
return pattern.apply(extent, get, mutable);
|
||||||
} else {
|
} else {
|
||||||
return pattern.apply(extent, set, get);
|
return pattern.apply(extent, get, set);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package com.boydti.fawe.object.pattern;
|
package com.boydti.fawe.object.pattern;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
@ -13,20 +14,16 @@ import java.util.concurrent.ThreadLocalRandom;
|
|||||||
|
|
||||||
public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
||||||
private final Pattern pattern;
|
private final Pattern pattern;
|
||||||
private int moves;
|
private final int moves;
|
||||||
|
|
||||||
private transient MutableBlockVector3 cur;
|
private final MutableBlockVector3 cur;
|
||||||
private transient MutableBlockVector3[] buffer;
|
private final MutableBlockVector3[] buffer;
|
||||||
private transient MutableBlockVector3[] allowed;
|
private final MutableBlockVector3[] allowed;
|
||||||
private transient MutableBlockVector3 next;
|
private MutableBlockVector3 next;
|
||||||
|
|
||||||
public SurfaceRandomOffsetPattern(Pattern pattern, int distance) {
|
public SurfaceRandomOffsetPattern(Pattern pattern, int distance) {
|
||||||
this.pattern = pattern;
|
this.pattern = pattern;
|
||||||
this.moves = Math.min(255, distance);
|
this.moves = Math.min(255, distance);
|
||||||
init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void init() {
|
|
||||||
cur = new MutableBlockVector3();
|
cur = new MutableBlockVector3();
|
||||||
this.buffer = new MutableBlockVector3[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length];
|
this.buffer = new MutableBlockVector3[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length];
|
||||||
for (int i = 0; i < buffer.length; i++) {
|
for (int i = 0; i < buffer.length; i++) {
|
||||||
@ -110,9 +107,4 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
|||||||
BlockStateHolder block = pattern.apply(v);
|
BlockStateHolder block = pattern.apply(v);
|
||||||
return !block.getBlockType().getMaterial().isMovementBlocker();
|
return !block.getBlockType().getMaterial().isMovementBlocker();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
|
||||||
stream.defaultReadObject();
|
|
||||||
init();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class FaweQueueDelegateExtent extends DelegateFaweQueue {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
public int getCombinedId4Data(int x, int y, int z) throws FaweException.FaweChunkLoadException {
|
||||||
return getLazyBlock(x, y, z).getInternalId();
|
return getBlock(x, y, z).getInternalId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,8 +61,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
default BlockState getLazyBlock(int x, int y, int z) {
|
default BlockState getBlock(int x, int y, int z) {
|
||||||
return getQueue().getLazyBlock(x, y, z);
|
return getQueue().getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -453,11 +453,6 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
|||||||
return getQueue().createEntity(location, entity);
|
return getQueue().createEntity(location, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
default BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return getQueue().getLazyBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
default Operation commit() {
|
default Operation commit() {
|
||||||
|
@ -1,25 +1,18 @@
|
|||||||
package com.boydti.fawe.util;
|
package com.boydti.fawe.util;
|
||||||
|
|
||||||
import com.boydti.fawe.Fawe;
|
import com.boydti.fawe.Fawe;
|
||||||
import com.boydti.fawe.FaweCache;
|
import com.boydti.fawe.beta.SingleFilterBlock;
|
||||||
import com.boydti.fawe.config.Settings;
|
import com.boydti.fawe.config.Settings;
|
||||||
import com.boydti.fawe.object.pattern.PatternExtent;
|
|
||||||
import com.boydti.fawe.util.image.ImageUtil;
|
import com.boydti.fawe.util.image.ImageUtil;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
|
||||||
import com.sk89q.worldedit.util.command.binding.Text;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
|
||||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||||
import com.sk89q.worldedit.function.mask.Mask;
|
import com.sk89q.worldedit.function.mask.Mask;
|
||||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
import com.sk89q.worldedit.world.registry.BlockMaterial;
|
||||||
import com.sk89q.worldedit.world.registry.BundledBlockData;
|
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
import it.unimi.dsi.fastutil.ints.IntArraySet;
|
import it.unimi.dsi.fastutil.ints.IntArraySet;
|
||||||
@ -27,12 +20,23 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
|
|||||||
|
|
||||||
import javax.imageio.ImageIO;
|
import javax.imageio.ImageIO;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
import java.lang.reflect.Type;
|
import java.lang.reflect.Type;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Enumeration;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
@ -61,14 +65,15 @@ public class TextureUtil implements TextureHolder {
|
|||||||
|
|
||||||
public static TextureUtil fromMask(Mask mask) throws FileNotFoundException {
|
public static TextureUtil fromMask(Mask mask) throws FileNotFoundException {
|
||||||
HashSet<BlockType> blocks = new HashSet<>();
|
HashSet<BlockType> blocks = new HashSet<>();
|
||||||
BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
|
|
||||||
PatternExtent extent = new PatternExtent(pattern);
|
SingleFilterBlock extent = new SingleFilterBlock();
|
||||||
new MaskTraverser(mask).reset(extent);
|
new MaskTraverser(mask).reset(extent);
|
||||||
|
|
||||||
TextureUtil tu = Fawe.get().getTextureUtil();
|
TextureUtil tu = Fawe.get().getTextureUtil();
|
||||||
for (int typeId : tu.getValidBlockIds()) {
|
for (int typeId : tu.getValidBlockIds()) {
|
||||||
BlockType block = BlockTypes.get(typeId);
|
BlockType block = BlockTypes.get(typeId);
|
||||||
pattern.setBlock(block.getDefaultState());
|
extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
|
||||||
if (mask.test(BlockVector3.ZERO)) {
|
if (mask.test(extent)) {
|
||||||
blocks.add(block);
|
blocks.add(block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -151,7 +151,7 @@ public class CuboidClipboard {
|
|||||||
|
|
||||||
/* ------------------------------------------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------------------------------------------- */
|
||||||
|
|
||||||
public BaseBlock getBlock(BlockVector3 position) {
|
public BaseBlock getLazyBlock(BlockVector3 position) {
|
||||||
return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
return getBlock(position.getBlockX(), position.getBlockY(), position.getBlockZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +161,7 @@ public class CuboidClipboard {
|
|||||||
return clipboard.IMP.getBlock(x, y, z);
|
return clipboard.IMP.getBlock(x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BaseBlock getLazyBlock(BlockVector3 position) {
|
public BaseBlock getBlock(BlockVector3 position) {
|
||||||
return getBlock(position);
|
return getBlock(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,6 +100,7 @@ import com.sk89q.worldedit.function.mask.MaskUnion;
|
|||||||
import com.sk89q.worldedit.function.mask.Masks;
|
import com.sk89q.worldedit.function.mask.Masks;
|
||||||
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
import com.sk89q.worldedit.function.mask.NoiseFilter2D;
|
||||||
import com.sk89q.worldedit.function.mask.RegionMask;
|
import com.sk89q.worldedit.function.mask.RegionMask;
|
||||||
|
import com.sk89q.worldedit.function.mask.SingleBlockTypeMask;
|
||||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||||
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
import com.sk89q.worldedit.function.operation.ChangeSetExecutor;
|
||||||
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
|
||||||
@ -164,7 +165,9 @@ import org.slf4j.LoggerFactory;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -203,15 +206,15 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
private final World world;
|
private final World world;
|
||||||
private final String worldName;
|
private final String worldName;
|
||||||
private final FaweQueue queue;
|
private final FaweQueue queue;
|
||||||
private final boolean wrapped;
|
private boolean wrapped;
|
||||||
private final boolean fastMode;
|
private boolean fastMode;
|
||||||
private final HistoryExtent history;
|
private final HistoryExtent history;
|
||||||
private AbstractDelegateExtent bypassHistory;
|
private AbstractDelegateExtent bypassHistory;
|
||||||
private AbstractDelegateExtent bypassAll;
|
private AbstractDelegateExtent bypassAll;
|
||||||
private final FaweLimit originalLimit;
|
private final FaweLimit originalLimit;
|
||||||
private final FaweLimit limit;
|
private final FaweLimit limit;
|
||||||
private final FawePlayer player;
|
private final FawePlayer player;
|
||||||
private final FaweChangeSet changeTask;
|
private FaweChangeSet changeTask;
|
||||||
|
|
||||||
private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
|
private final MutableBlockVector3 mutablebv = new MutableBlockVector3();
|
||||||
|
|
||||||
@ -294,6 +297,10 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
this(world, null, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
|
this(world, null, null, null, null, null, true, null, null, null, blockBag, eventBus, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setExtent(AbstractDelegateExtent extent) {
|
||||||
|
new ExtentTraverser(this).setNext(extent);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The limit for this specific edit (blocks etc)
|
* The limit for this specific edit (blocks etc)
|
||||||
*
|
*
|
||||||
@ -552,7 +559,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return mask, may be null
|
* @return mask, may be null
|
||||||
*/
|
*/
|
||||||
public Mask getMask() {
|
public Mask getMask() {
|
||||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(getExtent()).find(MaskingExtent.class);
|
||||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -562,28 +569,19 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return mask, may be null
|
* @return mask, may be null
|
||||||
*/
|
*/
|
||||||
public Mask getSourceMask() {
|
public Mask getSourceMask() {
|
||||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(getExtent()).find(SourceMaskExtent.class);
|
||||||
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
return maskingExtent != null ? maskingExtent.get().getMask() : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addTransform(ResettableExtent transform) {
|
public void addTransform(ResettableExtent transform) {
|
||||||
|
checkNotNull(transform);
|
||||||
wrapped = true;
|
wrapped = true;
|
||||||
if (transform == null) {
|
transform.setExtent(getExtent());
|
||||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
new ExtentTraverser(this).setNext(transform);
|
||||||
AbstractDelegateExtent next = extent;
|
|
||||||
while (traverser != null && traverser.get() instanceof ResettableExtent) {
|
|
||||||
traverser = traverser.next();
|
|
||||||
next = traverser.get();
|
|
||||||
}
|
|
||||||
this.extent = next;
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
this.extent = transform.setExtent(extent);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public @Nullable ResettableExtent getTransform() {
|
public @Nullable ResettableExtent getTransform() {
|
||||||
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(this.extent).find(ResettableExtent.class);
|
ExtentTraverser<AbstractDelegateExtent> traverser = new ExtentTraverser(getExtent()).find(ResettableExtent.class);
|
||||||
if (traverser != null) {
|
if (traverser != null) {
|
||||||
return (ResettableExtent) traverser.get();
|
return (ResettableExtent) traverser.get();
|
||||||
}
|
}
|
||||||
@ -601,7 +599,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
} else {
|
} else {
|
||||||
new MaskTraverser(mask).reset(this);
|
new MaskTraverser(mask).reset(this);
|
||||||
}
|
}
|
||||||
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(this.extent).find(SourceMaskExtent.class);
|
ExtentTraverser<SourceMaskExtent> maskingExtent = new ExtentTraverser(getExtent()).find(SourceMaskExtent.class);
|
||||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||||
Mask oldMask = maskingExtent.get().getMask();
|
Mask oldMask = maskingExtent.get().getMask();
|
||||||
if (oldMask instanceof ResettableMask) {
|
if (oldMask instanceof ResettableMask) {
|
||||||
@ -609,7 +607,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
maskingExtent.get().setMask(mask);
|
maskingExtent.get().setMask(mask);
|
||||||
} else if (mask != Masks.alwaysTrue()) {
|
} else if (mask != Masks.alwaysTrue()) {
|
||||||
this.extent = new SourceMaskExtent(this.extent, mask);
|
SourceMaskExtent next = new SourceMaskExtent(getExtent(), mask);
|
||||||
|
new ExtentTraverser(this).setNext(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,13 +617,13 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
Mask existing = getSourceMask();
|
Mask existing = getSourceMask();
|
||||||
if (existing != null) {
|
if (existing != null) {
|
||||||
if (existing instanceof MaskIntersection) {
|
if (existing instanceof MaskIntersection) {
|
||||||
((MaskIntersection) existing).add(mask);
|
Collection<Mask> masks = new HashSet<>(((MaskIntersection) existing).getMasks());
|
||||||
return;
|
masks.add(mask);
|
||||||
|
mask = new MaskIntersection(masks);
|
||||||
} else {
|
} else {
|
||||||
MaskIntersection intersection = new MaskIntersection(existing);
|
mask = new MaskIntersection(existing, mask);
|
||||||
intersection.add(mask);
|
|
||||||
mask = intersection;
|
|
||||||
}
|
}
|
||||||
|
mask = mask.optimize();
|
||||||
}
|
}
|
||||||
setSourceMask(mask);
|
setSourceMask(mask);
|
||||||
}
|
}
|
||||||
@ -640,7 +639,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
} else {
|
} else {
|
||||||
new MaskTraverser(mask).reset(this);
|
new MaskTraverser(mask).reset(this);
|
||||||
}
|
}
|
||||||
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(this.extent).find(MaskingExtent.class);
|
ExtentTraverser<MaskingExtent> maskingExtent = new ExtentTraverser(getExtent()).find(MaskingExtent.class);
|
||||||
if (maskingExtent != null && maskingExtent.get() != null) {
|
if (maskingExtent != null && maskingExtent.get() != null) {
|
||||||
Mask oldMask = maskingExtent.get().getMask();
|
Mask oldMask = maskingExtent.get().getMask();
|
||||||
if (oldMask instanceof ResettableMask) {
|
if (oldMask instanceof ResettableMask) {
|
||||||
@ -648,7 +647,8 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
maskingExtent.get().setMask(mask);
|
maskingExtent.get().setMask(mask);
|
||||||
} else if (mask != Masks.alwaysTrue()) {
|
} else if (mask != Masks.alwaysTrue()) {
|
||||||
this.extent = new MaskingExtent(this.extent, mask);
|
MaskingExtent next = new MaskingExtent(getExtent(), mask);
|
||||||
|
new ExtentTraverser(this).setNext(next);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -658,13 +658,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return the survival simulation extent
|
* @return the survival simulation extent
|
||||||
*/
|
*/
|
||||||
public SurvivalModeExtent getSurvivalExtent() {
|
public SurvivalModeExtent getSurvivalExtent() {
|
||||||
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(this.extent).find(SurvivalModeExtent.class);
|
ExtentTraverser<SurvivalModeExtent> survivalExtent = new ExtentTraverser(getExtent()).find(SurvivalModeExtent.class);
|
||||||
if (survivalExtent != null) {
|
if (survivalExtent != null) {
|
||||||
return survivalExtent.get();
|
return survivalExtent.get();
|
||||||
} else {
|
} else {
|
||||||
AbstractDelegateExtent extent = this.extent;
|
SurvivalModeExtent survival = new SurvivalModeExtent(bypassAll.getExtent(), getWorld());
|
||||||
SurvivalModeExtent survival = new SurvivalModeExtent(extent.getExtent(), getWorld());
|
new ExtentTraverser(bypassAll).setNext(survival);
|
||||||
new ExtentTraverser(extent).setNext(survival);
|
|
||||||
return survival;
|
return survival;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -691,7 +690,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
if (history == null) {
|
if (history == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ExtentTraverser traverseHistory = new ExtentTraverser(this.extent).find(HistoryExtent.class);
|
ExtentTraverser traverseHistory = new ExtentTraverser(getExtent()).find(HistoryExtent.class);
|
||||||
if (disableHistory) {
|
if (disableHistory) {
|
||||||
if (traverseHistory != null && traverseHistory.exists()) {
|
if (traverseHistory != null && traverseHistory.exists()) {
|
||||||
ExtentTraverser beforeHistory = traverseHistory.previous();
|
ExtentTraverser beforeHistory = traverseHistory.previous();
|
||||||
@ -699,11 +698,11 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
if (beforeHistory != null && beforeHistory.exists()) {
|
if (beforeHistory != null && beforeHistory.exists()) {
|
||||||
beforeHistory.setNext(afterHistory.get());
|
beforeHistory.setNext(afterHistory.get());
|
||||||
} else {
|
} else {
|
||||||
extent = (AbstractDelegateExtent) afterHistory.get();
|
new ExtentTraverser(this).setNext(afterHistory.get());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (traverseHistory == null || !traverseHistory.exists()) {
|
} else if (traverseHistory == null || !traverseHistory.exists()) {
|
||||||
ExtentTraverser traverseBypass = new ExtentTraverser(this.extent).find(bypassHistory);
|
ExtentTraverser traverseBypass = new ExtentTraverser(getExtent()).find(bypassHistory);
|
||||||
if (traverseBypass != null) {
|
if (traverseBypass != null) {
|
||||||
ExtentTraverser beforeHistory = traverseBypass.previous();
|
ExtentTraverser beforeHistory = traverseBypass.previous();
|
||||||
beforeHistory.setNext(history);
|
beforeHistory.setNext(history);
|
||||||
@ -750,7 +749,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
if (changeSet instanceof BlockBagChangeSet) {
|
if (changeSet instanceof BlockBagChangeSet) {
|
||||||
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
missingBlocks = ((BlockBagChangeSet) changeSet).popMissing();
|
||||||
} else {
|
} else {
|
||||||
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser(extent).find(BlockBagExtent.class);
|
ExtentTraverser<BlockBagExtent> find = new ExtentTraverser(getExtent()).find(BlockBagExtent.class);
|
||||||
if (find != null && find.get() != null) {
|
if (find != null && find.get() != null) {
|
||||||
missingBlocks = find.get().popMissing();
|
missingBlocks = find.get().popMissing();
|
||||||
} else {
|
} else {
|
||||||
@ -1068,7 +1067,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
@Override
|
@Override
|
||||||
@Nullable
|
@Nullable
|
||||||
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
public Entity createEntity(final com.sk89q.worldedit.util.Location location, final BaseEntity entity) {
|
||||||
Entity result = this.extent.createEntity(location, entity);
|
Entity result = getExtent().createEntity(location, entity);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1142,30 +1141,22 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMinimumPoint() {
|
public BlockVector3 getMinimumPoint() {
|
||||||
if (extent != null) {
|
return getExtent().getMinimumPoint();
|
||||||
return this.extent.getMinimumPoint();
|
|
||||||
} else {
|
|
||||||
return BlockVector3.at(-30000000, 0, -30000000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockVector3 getMaximumPoint() {
|
public BlockVector3 getMaximumPoint() {
|
||||||
if (extent != null) {
|
return getExtent().getMaximumPoint();
|
||||||
return this.extent.getMaximumPoint();
|
|
||||||
} else {
|
|
||||||
return BlockVector3.at(30000000, 255, 30000000);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities(final Region region) {
|
public List<? extends Entity> getEntities(final Region region) {
|
||||||
return this.extent.getEntities(region);
|
return getExtent().getEntities(region);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Entity> getEntities() {
|
public List<? extends Entity> getEntities() {
|
||||||
return this.extent.getEntities();
|
return getExtent().getEntities();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1186,7 +1177,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Nullable Operation commit() {
|
public @Nullable Operation commit() {
|
||||||
return extent.commit();
|
return getExtent().commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1285,7 +1276,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
* @return the number of blocks that matched the pattern
|
* @return the number of blocks that matched the pattern
|
||||||
*/
|
*/
|
||||||
public int countBlocks(final Region region, final Set<BlockStateHolder> searchBlocks) {
|
public int countBlocks(final Region region, final Set<BlockStateHolder> searchBlocks) {
|
||||||
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(extent);
|
Mask mask = new BlockMaskBuilder().addBlocks(searchBlocks).build(getExtent());
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() {
|
||||||
@Override
|
@Override
|
||||||
public boolean apply(BlockVector3 position) throws WorldEditException {
|
public boolean apply(BlockVector3 position) throws WorldEditException {
|
||||||
@ -1514,7 +1505,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
checkNotNull(position);
|
checkNotNull(position);
|
||||||
checkArgument(apothem >= 1, "apothem >= 1");
|
checkArgument(apothem >= 1, "apothem >= 1");
|
||||||
|
|
||||||
Mask mask = new BlockTypeMask(this, blockType);
|
Mask mask = new SingleBlockTypeMask(this, blockType);
|
||||||
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
|
BlockVector3 adjustment = BlockVector3.ONE.multiply(apothem - 1);
|
||||||
Region region = new CuboidRegion(
|
Region region = new CuboidRegion(
|
||||||
getWorld(), // Causes clamping of Y range
|
getWorld(), // Causes clamping of Y range
|
||||||
@ -1542,12 +1533,12 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (hasExtraExtents()) {
|
if (hasExtraExtents()) {
|
||||||
RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(extent, (block)), this);
|
RegionVisitor visitor = new RegionVisitor(region, new BlockReplace(getExtent(), (block)), this);
|
||||||
Operations.completeBlindly(visitor);
|
Operations.completeBlindly(visitor);
|
||||||
this.changes += visitor.getAffected();
|
this.changes += visitor.getAffected();
|
||||||
} else {
|
} else {
|
||||||
for (BlockVector3 blockVector3 : region) {
|
for (BlockVector3 blockVector3 : region) {
|
||||||
if (this.extent.setBlock(blockVector3, block)) {
|
if (getExtent().setBlock(blockVector3, block)) {
|
||||||
changes++;
|
changes++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2004,7 +1995,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
new RegionMask(new EllipsoidRegion(null, origin, Vector3.at(radius, radius, radius))),
|
||||||
blockMask);
|
blockMask);
|
||||||
|
|
||||||
BlockReplace replace = new BlockReplace(this, new BlockPattern(fluid.getDefaultState()));
|
BlockReplace replace = new BlockReplace(this, fluid.getDefaultState());
|
||||||
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
NonRisingVisitor visitor = new NonRisingVisitor(mask, replace);
|
||||||
|
|
||||||
// Around the origin in a 3x3 block
|
// Around the origin in a 3x3 block
|
||||||
@ -2917,7 +2908,7 @@ public class EditSession extends AbstractDelegateExtent implements HasFaweQueue,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.changes++;
|
this.changes++;
|
||||||
pattern.apply(this.extent, position, position);
|
pattern.apply(getExtent(), position, position);
|
||||||
}
|
}
|
||||||
} catch (WorldEditException e) {
|
} catch (WorldEditException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
|
@ -19,6 +19,9 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.blocks;
|
package com.sk89q.worldedit.blocks;
|
||||||
|
|
||||||
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import com.sk89q.jnbt.StringTag;
|
||||||
|
import com.sk89q.jnbt.Tag;
|
||||||
import com.sk89q.worldedit.world.NbtValued;
|
import com.sk89q.worldedit.world.NbtValued;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -34,6 +37,17 @@ public interface TileEntityBlock extends NbtValued {
|
|||||||
*
|
*
|
||||||
* @return tile entity ID, non-null string
|
* @return tile entity ID, non-null string
|
||||||
*/
|
*/
|
||||||
String getNbtId();
|
default String getNbtId() {
|
||||||
|
CompoundTag nbtData = getNbtData();
|
||||||
|
if (nbtData == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
Tag idTag = nbtData.getValue().get("id");
|
||||||
|
if (idTag instanceof StringTag) {
|
||||||
|
return ((StringTag) idTag).getValue();
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -235,7 +235,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 2,
|
min = 2,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
public Pattern iddatamask(Actor actor, LocalSession session, Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
|
public Pattern iddatamask(Extent extent, @Range(min = 0, max = 15) int bitmask, Pattern pattern) {
|
||||||
return new IdDataMaskPattern(extent, pattern, bitmask);
|
return new IdDataMaskPattern(extent, pattern, bitmask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern id(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern id(Extent extent, Pattern pattern) {
|
||||||
return new IdPattern(extent, pattern);
|
return new IdPattern(extent, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -257,7 +257,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern data(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern data(Extent extent, Pattern pattern) {
|
||||||
return new DataPattern(extent, pattern);
|
return new DataPattern(extent, pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern biome(Actor actor, LocalSession session, Extent extent, BiomeType biome) {
|
public Pattern biome(Extent extent, BiomeType biome) {
|
||||||
return new BiomePattern(extent, biome);
|
return new BiomePattern(extent, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,7 +279,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern relative(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern relative(Pattern pattern) {
|
||||||
return new RelativePattern(pattern);
|
return new RelativePattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,7 +292,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern nox(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern nox(Pattern pattern) {
|
||||||
return new NoXPattern(pattern);
|
return new NoXPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -303,7 +303,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern noy(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern noy(Pattern pattern) {
|
||||||
return new NoYPattern(pattern);
|
return new NoYPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -314,7 +314,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern noz(Actor actor, LocalSession session, Extent extent, Pattern pattern) {
|
public Pattern noz(Pattern pattern) {
|
||||||
return new NoZPattern(pattern);
|
return new NoZPattern(pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -325,9 +325,8 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 3,
|
min = 3,
|
||||||
max = 3
|
max = 3
|
||||||
)
|
)
|
||||||
public Pattern mask(Actor actor, LocalSession session, Mask mask, Pattern pass, Pattern fail) {
|
public Pattern mask(Mask mask, Pattern pass, @Optional Pattern fail) {
|
||||||
PatternExtent extent = new PatternExtent(pass);
|
return new MaskedPattern(mask, pass, fail);
|
||||||
return new MaskedPattern(mask, extent, fail);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Command(
|
@Command(
|
||||||
@ -337,7 +336,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 4,
|
min = 4,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
public Pattern offset(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern offset(double x, double y, double z, Pattern pattern) {
|
||||||
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new OffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -348,7 +347,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 2,
|
min = 2,
|
||||||
max = 2
|
max = 2
|
||||||
)
|
)
|
||||||
public Pattern surfacespread(Actor actor, LocalSession session, double distance, Pattern pattern) {
|
public Pattern surfacespread(double distance, Pattern pattern) {
|
||||||
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
return new SurfaceRandomOffsetPattern(pattern, (int) distance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -359,7 +358,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 4,
|
min = 4,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
public Pattern solidspread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern solidspread(double x, double y, double z, Pattern pattern) {
|
||||||
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new SolidRandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -370,7 +369,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 4,
|
min = 4,
|
||||||
max = 4
|
max = 4
|
||||||
)
|
)
|
||||||
public Pattern spread(Actor actor, LocalSession session, double x, double y, double z, Pattern pattern) {
|
public Pattern spread(double x, double y, double z, Pattern pattern) {
|
||||||
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
return new RandomOffsetPattern(pattern, (int) x, (int) y, (int) z);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -381,7 +380,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern linear(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear(Pattern other) {
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new LinearBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -396,7 +395,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern linear3d(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear3d(Pattern other) {
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new Linear3DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -411,7 +410,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern linear2d(Actor actor, LocalSession session, Pattern other) {
|
public Pattern linear2d(Pattern other) {
|
||||||
if (other instanceof RandomPattern) {
|
if (other instanceof RandomPattern) {
|
||||||
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
Set<Pattern> patterns = ((RandomPattern) other).getPatterns();
|
||||||
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
return new Linear2DBlockPattern(patterns.toArray(new Pattern[patterns.size()]));
|
||||||
@ -426,7 +425,7 @@ public class PatternCommands extends MethodCommands {
|
|||||||
min = 1,
|
min = 1,
|
||||||
max = 1
|
max = 1
|
||||||
)
|
)
|
||||||
public Pattern expression(Actor actor, LocalSession session, Extent extent, String input) throws ExpressionException {
|
public Pattern expression(Extent extent, String input) throws ExpressionException {
|
||||||
Expression exp = Expression.compile(input, "x", "y", "z");
|
Expression exp = Expression.compile(input, "x", "y", "z");
|
||||||
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
WorldEditExpressionEnvironment env = new WorldEditExpressionEnvironment(extent, Vector3.ONE, Vector3.ZERO);
|
||||||
exp.setEnvironment(env);
|
exp.setEnvironment(env);
|
||||||
|
@ -25,6 +25,7 @@ import com.boydti.fawe.object.clipboard.URIClipboardHolder;
|
|||||||
import com.boydti.fawe.object.mask.IdMask;
|
import com.boydti.fawe.object.mask.IdMask;
|
||||||
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
import com.boydti.fawe.object.regions.selector.FuzzyRegionSelector;
|
||||||
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
import com.boydti.fawe.object.regions.selector.PolyhedralRegionSelector;
|
||||||
|
import com.boydti.fawe.util.ExtentTraverser;
|
||||||
import com.sk89q.minecraft.util.commands.Command;
|
import com.sk89q.minecraft.util.commands.Command;
|
||||||
import com.sk89q.minecraft.util.commands.CommandContext;
|
import com.sk89q.minecraft.util.commands.CommandContext;
|
||||||
import com.sk89q.minecraft.util.commands.CommandException;
|
import com.sk89q.minecraft.util.commands.CommandException;
|
||||||
@ -702,7 +703,7 @@ public class SelectionCommands {
|
|||||||
// TODO multi clipboard distribution
|
// TODO multi clipboard distribution
|
||||||
Clipboard clipboard = session.getClipboard().getClipboard();
|
Clipboard clipboard = session.getClipboard().getClipboard();
|
||||||
region = clipboard.getRegion();
|
region = clipboard.getRegion();
|
||||||
editSession.setExtent(new AbstractDelegateExtent(clipboard));
|
new ExtentTraverser<AbstractDelegateExtent>(editSession).setNext(new AbstractDelegateExtent(clipboard));
|
||||||
} else {
|
} else {
|
||||||
region = session.getSelection(player.getWorld());
|
region = session.getSelection(player.getWorld());
|
||||||
}
|
}
|
||||||
|
@ -609,9 +609,6 @@ public class BrushTool implements DoubleActionTraceTool, ScrollTool, MovableTool
|
|||||||
.blockBag(null)
|
.blockBag(null)
|
||||||
.changeSetNull()
|
.changeSetNull()
|
||||||
.combineStages(false);
|
.combineStages(false);
|
||||||
|
|
||||||
builder.commit();
|
|
||||||
|
|
||||||
EditSession editSession = builder.build();
|
EditSession editSession = builder.build();
|
||||||
|
|
||||||
VisualExtent newVisualExtent = new VisualExtent(builder.getExtent(), builder.getQueue());
|
VisualExtent newVisualExtent = new VisualExtent(builder.getExtent(), builder.getQueue());
|
||||||
|
@ -57,7 +57,7 @@ public class AbstractDelegateExtent implements Extent, LightingExtent {
|
|||||||
*
|
*
|
||||||
* @return the extent
|
* @return the extent
|
||||||
*/
|
*/
|
||||||
public final Extent getExtent() {
|
public Extent getExtent() {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,15 +72,10 @@ public class NullExtent implements Extent {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return BlockTypes.AIR.getDefaultState();
|
return BlockTypes.AIR.getDefaultState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return BlockTypes.AIR.getDefaultState();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
return getBlock(position).toBaseBlock();
|
return getBlock(position).toBaseBlock();
|
||||||
|
@ -208,11 +208,6 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
return IMP.getBlock(x, y, z).toImmutableState();
|
return IMP.getBlock(x, y, z).toImmutableState();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return getBlock(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||||
if(region.contains(position)) {
|
if(region.contains(position)) {
|
||||||
@ -290,11 +285,11 @@ public class BlockArrayClipboard implements Clipboard, LightingExtent, Closeable
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getOpacity(int x, int y, int z) {
|
public int getOpacity(int x, int y, int z) {
|
||||||
return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightOpacity();
|
return getBlock(x, y, z).getBlockType().getMaterial().getLightOpacity();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getBrightness(int x, int y, int z) {
|
public int getBrightness(int x, int y, int z) {
|
||||||
return getBlock(BlockVector3.at(x, y, z)).getBlockType().getMaterial().getLightValue();
|
return getBlock(x, y, z).getBlockType().getMaterial().getLightValue();
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -93,7 +93,7 @@ public class BlockBagExtent extends AbstractDelegateExtent {
|
|||||||
@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 {
|
||||||
if(blockBag != null) {
|
if(blockBag != null) {
|
||||||
BlockStateHolder lazyBlock = getExtent().getLazyBlock(x, y, z);
|
BlockStateHolder lazyBlock = getExtent().getBlock(x, y, z);
|
||||||
BlockType fromType = lazyBlock.getBlockType();
|
BlockType fromType = lazyBlock.getBlockType();
|
||||||
if(!block.getBlockType().equals(fromType)) {
|
if(!block.getBlockType().equals(fromType)) {
|
||||||
BlockType type = block.getBlockType();
|
BlockType type = block.getBlockType();
|
||||||
|
@ -442,8 +442,8 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getLazyBlock(int x, int y, int z) {
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
return transform(super.getLazyBlock(x, y, z));
|
return transform(super.getBlock(x, y, z));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -451,11 +451,6 @@ public class BlockTransformExtent extends ResettableExtent {
|
|||||||
return transform(super.getFullBlock(position));
|
return transform(super.getFullBlock(position));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public BlockState getLazyBlock(BlockVector3 position) {
|
|
||||||
return transform(super.getLazyBlock(position));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public BlockState getBlock(BlockVector3 position) {
|
public BlockState getBlock(BlockVector3 position) {
|
||||||
return transform(super.getBlock(position));
|
return transform(super.getBlock(position));
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.util.StringMan;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.util.command.parametric.Optional;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public abstract class ABlockMask extends AbstractExtentMask {
|
||||||
|
public ABlockMask(Extent extent) {
|
||||||
|
super(extent);
|
||||||
|
}
|
||||||
|
|
||||||
|
public abstract boolean test(BlockState state);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
List<String> strings = new ArrayList<>();
|
||||||
|
for (BlockType type : BlockTypes.values) {
|
||||||
|
if (type != null) {
|
||||||
|
boolean hasAll = true;
|
||||||
|
boolean hasAny = false;
|
||||||
|
List<BlockState> all = type.getAllStates();
|
||||||
|
for (BlockState state : all) {
|
||||||
|
hasAll &= test(state);
|
||||||
|
hasAny = true;
|
||||||
|
}
|
||||||
|
if (hasAll) {
|
||||||
|
strings.add(type.getId());
|
||||||
|
} else if (hasAny) {
|
||||||
|
for (BlockState state : all) {
|
||||||
|
if (test(state)) {
|
||||||
|
strings.add(state.getAsString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return StringMan.join(strings, ",");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask and(Mask mask) {
|
||||||
|
if (mask instanceof ABlockMask) {
|
||||||
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
BlockMask newMask = new BlockMask(getExtent());
|
||||||
|
for (BlockState state : BlockTypes.states) {
|
||||||
|
if (state != null) {
|
||||||
|
if (test(state) && other.test(state)) {
|
||||||
|
newMask.add(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mask tmp = newMask.optimize();
|
||||||
|
if (tmp == null) tmp = newMask;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask or(Mask mask) {
|
||||||
|
if (mask instanceof ABlockMask) {
|
||||||
|
ABlockMask other = (ABlockMask) mask;
|
||||||
|
BlockMask newMask = new BlockMask(getExtent());
|
||||||
|
for (BlockState state : BlockTypes.states) {
|
||||||
|
if (state != null) {
|
||||||
|
if (test(state) || other.test(state)) {
|
||||||
|
newMask.add(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Mask tmp = newMask.optimize();
|
||||||
|
if (tmp == null) tmp = newMask;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -44,7 +44,7 @@ public abstract class AbstractExtentMask extends AbstractMask {
|
|||||||
*
|
*
|
||||||
* @return the extent
|
* @return the extent
|
||||||
*/
|
*/
|
||||||
public Extent getExtent() {
|
public final Extent getExtent() {
|
||||||
return extent;
|
return extent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockCategory;
|
import com.sk89q.worldedit.world.block.BlockCategory;
|
||||||
@ -42,7 +43,7 @@ public class BlockCategoryMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return category.contains(getExtent().getBlock(vector));
|
return category.contains(vector.getBlock(getExtent()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -1,250 +1,194 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import com.boydti.fawe.object.collection.FastBitSet;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.boydti.fawe.util.MainUtil;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.boydti.fawe.util.StringMan;
|
|
||||||
import com.sk89q.worldedit.extent.NullExtent;
|
|
||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.registry.state.AbstractProperty;
|
|
||||||
import com.sk89q.worldedit.registry.state.Property;
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
/**
|
public class BlockMask extends ABlockMask {
|
||||||
* A mask that checks whether blocks at the given positions are matched by
|
private final boolean[] ordinals;
|
||||||
* a block in a list.
|
|
||||||
*
|
|
||||||
* <p>This mask checks for both an exact block type and state value match,
|
|
||||||
* respecting fuzzy status of the BlockState.</p>
|
|
||||||
*/
|
|
||||||
public class BlockMask extends AbstractExtentMask {
|
|
||||||
|
|
||||||
private final long[][] bitSets;
|
public BlockMask(Extent extent) {
|
||||||
protected final static long[] ALL = new long[0];
|
this(extent, new boolean[BlockTypes.states.length]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask(Extent extent, boolean[] ordinals) {
|
||||||
|
super(extent);
|
||||||
|
this.ordinals = ordinals;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated NBT not supported by this mask
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
public BlockMask(Extent extent, Collection<BaseBlock> blocks) {
|
||||||
super(extent);
|
this(extent);
|
||||||
MainUtil.warnDeprecated(BlockMaskBuilder.class);
|
add(blocks);
|
||||||
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BlockMask add(Predicate<BlockState> predicate) {
|
||||||
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
|
if (!ordinals[i]) {
|
||||||
|
BlockState state = BlockTypes.states[i];
|
||||||
|
if (state != null) ordinals[i] = predicate.test(state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask add(BlockState... states) {
|
||||||
|
addStates(Arrays.asList(states));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask addStates(Collection<BlockState> states) {
|
||||||
|
for (BlockState state : states) ordinals[state.getOrdinal()] = true;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask add(BlockType... types) {
|
||||||
|
addTypes(Arrays.asList(types));
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockMask addTypes(Collection<BlockType> types) {
|
||||||
|
for (BlockType type : types) {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated NBT not supported by this mask
|
||||||
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public BlockMask(Extent extent, BaseBlock... blocks) {
|
public void add(Collection<BaseBlock> blocks) {
|
||||||
super(extent);
|
for (BaseBlock block : blocks) {
|
||||||
MainUtil.warnDeprecated(BlockMaskBuilder.class);
|
add(block.toBlockState());
|
||||||
this.bitSets = new BlockMaskBuilder().addBlocks(blocks).optimize().getBits();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMask() {
|
|
||||||
super(NullExtent.INSTANCE);
|
|
||||||
this.bitSets = new long[BlockTypes.size()][];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected BlockMask(Extent extent, long[][] bitSets) {
|
|
||||||
super(extent);
|
|
||||||
this.bitSets = bitSets;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockMaskBuilder toBuilder() {
|
|
||||||
return new BlockMaskBuilder(this.bitSets);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public boolean test(BlockState state) {
|
||||||
List<String> strings = new ArrayList<>();
|
return ordinals[state.getOrdinal()];
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
|
||||||
if (bitSets[i] != null) {
|
|
||||||
long[] set = bitSets[i];
|
|
||||||
BlockType type = BlockTypes.get(i);
|
|
||||||
if (set == ALL) {
|
|
||||||
strings.add(type.getId());
|
|
||||||
} else {
|
|
||||||
for (BlockState state : type.getAllStates()) {
|
|
||||||
if (test(state)) {
|
|
||||||
strings.add(state.getAsString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return StringMan.join(strings, ",");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask optimize() {
|
public boolean test(BlockVector3 vector) {
|
||||||
Map<Object, Integer> states = new HashMap<>();
|
return ordinals[vector.getOrdinal(getExtent())];
|
||||||
int indexFound = -1;
|
|
||||||
{
|
|
||||||
int indexNull = -1;
|
|
||||||
int indexAll = -1;
|
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
|
||||||
long[] bs = bitSets[i];
|
|
||||||
if (bs == null) {
|
|
||||||
indexNull = i;
|
|
||||||
states.put(null, states.getOrDefault(null, 0) + 1);
|
|
||||||
} else if (bs.length == 0) {
|
|
||||||
indexAll = i;
|
|
||||||
states.put(ALL, states.getOrDefault(ALL, 0) + 1);
|
|
||||||
} else if (indexFound == -1) {
|
|
||||||
indexFound = i;
|
|
||||||
} else {
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Only types, no states
|
|
||||||
if (indexFound == -1) {
|
|
||||||
if (states.size() == 1) {
|
|
||||||
return states.keySet().iterator().next() == null ? Masks.alwaysFalse() : Masks.alwaysTrue();
|
|
||||||
}
|
|
||||||
if (states.get(ALL) == 1) return new SingleBlockTypeMask(getExtent(), BlockTypes.get(indexAll));
|
|
||||||
if (states.get(null) == 1)
|
|
||||||
return new SingleBlockTypeMask(getExtent(), BlockTypes.get(indexNull)).inverse();
|
|
||||||
|
|
||||||
boolean[] types = new boolean[BlockTypes.size()];
|
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
|
||||||
if (bitSets[i].length == 0) types[i] = true;
|
|
||||||
}
|
|
||||||
return new BlockTypeMask(getExtent(), types);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BlockType type = BlockTypes.get(indexFound);
|
|
||||||
{
|
|
||||||
Mask mask = getOptimizedMask(type, bitSets[indexFound]);
|
|
||||||
if (mask == null) { // Try with inverse
|
|
||||||
long[] newBitSet = bitSets[indexFound];
|
|
||||||
for (int i = 0; i < newBitSet.length; i++) newBitSet[i] = ~newBitSet[i];
|
|
||||||
mask = getOptimizedMask(type, bitSets[indexFound]);
|
|
||||||
if (mask != null) mask = mask.inverse();
|
|
||||||
}
|
|
||||||
return mask;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private Mask getOptimizedMask(BlockType type, long[] bitSet) {
|
|
||||||
boolean single = true;
|
|
||||||
int and = type.getInternalId();
|
|
||||||
List<? extends Property> properties = type.getProperties();
|
|
||||||
for (AbstractProperty prop : (List<AbstractProperty<?>>) type.getProperties()) {
|
|
||||||
List values = prop.getValues();
|
|
||||||
int numSet = 0;
|
|
||||||
for (int i = 0; i < values.size(); i++) {
|
|
||||||
int localI = i << prop.getBitOffset();
|
|
||||||
if (FastBitSet.get(bitSet, localI)) {
|
|
||||||
numSet++;
|
|
||||||
and |= prop.modify(and, i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Cannot optimize multiple property values - use current mask (null)
|
|
||||||
if (numSet != values.size() && numSet != 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
single = single && numSet == 1;
|
|
||||||
}
|
|
||||||
if (single)
|
|
||||||
return new SingleBlockStateMask(getExtent(), BlockState.getFromInternalId(and));
|
|
||||||
return new SingleBlockStateBitMask(getExtent(), and);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask and(Mask other) {
|
public Mask and(Mask mask) {
|
||||||
if (other instanceof BlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
long[][] otherBitSets = ((BlockMask) other).bitSets;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
for (int i = 0; i < otherBitSets.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
long[] otherBitSet = otherBitSets[i];
|
if (ordinals[i]) {
|
||||||
long[] bitSet = bitSets[i];
|
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
||||||
if (otherBitSet == null) bitSets[i] = null;
|
}
|
||||||
else if (otherBitSet.length == 0) continue;
|
|
||||||
else if (bitSet == null) continue;
|
|
||||||
else if (bitSet.length == 0) bitSets[i] = otherBitSet;
|
|
||||||
else for (int j = 0; j < otherBitSet.length; j++) bitSet[j] &= otherBitSet[j];
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (other instanceof SingleBlockStateMask) {
|
|
||||||
return new BlockMaskBuilder(bitSets).filter(((SingleBlockStateMask) other).getBlockState()).build(getExtent());
|
|
||||||
}
|
|
||||||
if (other instanceof SingleBlockTypeMask) {
|
|
||||||
return new BlockMaskBuilder(bitSets).filter(((SingleBlockTypeMask) other).getBlockType()).build(getExtent());
|
|
||||||
}
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask other) {
|
public Mask or(Mask mask) {
|
||||||
if (other instanceof BlockMask) {
|
if (mask instanceof ABlockMask) {
|
||||||
long[][] otherBitSets = ((BlockMask) other).bitSets;
|
ABlockMask other = (ABlockMask) mask;
|
||||||
for (int i = 0; i < otherBitSets.length; i++) {
|
for (int i = 0; i < ordinals.length; i++) {
|
||||||
long[] otherBitSet = otherBitSets[i];
|
if (!ordinals[i]) {
|
||||||
long[] bitSet = bitSets[i];
|
ordinals[i] = other.test(BlockState.getFromOrdinal(i));
|
||||||
if (otherBitSet == null) continue;
|
}
|
||||||
else if (otherBitSet.length == 0) bitSets[i] = ALL;
|
|
||||||
else if (bitSet == null) bitSets[i] = otherBitSet;
|
|
||||||
else if (bitSet.length == 0) continue;
|
|
||||||
else for (int j = 0; j < otherBitSet.length; j++) bitSet[j] |= otherBitSet[j];
|
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (other instanceof SingleBlockStateMask) {
|
return null;
|
||||||
return new BlockMaskBuilder(bitSets).add(((SingleBlockStateMask) other).getBlockState()).build(getExtent());
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask optimize() {
|
||||||
|
int setStates = 0;
|
||||||
|
BlockState setState = null;
|
||||||
|
BlockState unsetState = null;
|
||||||
|
int totalStates = 0;
|
||||||
|
|
||||||
|
int setTypes = 0;
|
||||||
|
BlockType setType = null;
|
||||||
|
BlockType unsetType = null;
|
||||||
|
int totalTypes = 0;
|
||||||
|
|
||||||
|
for (BlockType type : BlockTypes.values) {
|
||||||
|
if (type != null) {
|
||||||
|
totalTypes++;
|
||||||
|
boolean hasAll = true;
|
||||||
|
boolean hasAny = false;
|
||||||
|
List<BlockState> all = type.getAllStates();
|
||||||
|
for (BlockState state : all) {
|
||||||
|
totalStates++;
|
||||||
|
hasAll &= test(state);
|
||||||
|
hasAny = true;
|
||||||
|
}
|
||||||
|
if (hasAll) {
|
||||||
|
setTypes++;
|
||||||
|
setType = type;
|
||||||
|
setStates += all.size();
|
||||||
|
setState = type.getDefaultState();
|
||||||
|
} else if (hasAny) {
|
||||||
|
for (BlockState state : all) {
|
||||||
|
if (test(state)) {
|
||||||
|
setStates++;
|
||||||
|
setState = state;
|
||||||
|
} else {
|
||||||
|
unsetState = state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
unsetType = type;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (other instanceof SingleBlockTypeMask) {
|
if (setStates == 0) {
|
||||||
return new BlockMaskBuilder(bitSets).add(((SingleBlockTypeMask) other).getBlockType()).build(getExtent());
|
return Masks.alwaysFalse();
|
||||||
}
|
}
|
||||||
|
if (setStates == totalStates) {
|
||||||
|
return Masks.alwaysTrue();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setStates == 1) {
|
||||||
|
return new SingleBlockStateMask(getExtent(), setState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setStates == totalStates - 1) {
|
||||||
|
return new InverseSingleBlockStateMask(getExtent(), unsetState);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setTypes == 1) {
|
||||||
|
return new SingleBlockTypeMask(getExtent(), setType);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (setTypes == totalTypes - 1) {
|
||||||
|
return new InverseSingleBlockTypeMask(getExtent(), unsetType);
|
||||||
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask inverse() {
|
public Mask inverse() {
|
||||||
long[][] cloned = bitSets.clone();
|
boolean[] cloned = ordinals.clone();
|
||||||
for (int i = 0; i < cloned.length; i++) {
|
for (int i = 0; i < cloned.length; i++) cloned[i] = !cloned[i];
|
||||||
if (cloned[i] == null) cloned[i] = ALL;
|
|
||||||
else if (cloned[i] == ALL) cloned[i] = null;
|
|
||||||
else {
|
|
||||||
for (int j = 0; j < cloned[i].length; j++)
|
|
||||||
cloned[i][j] = ~cloned[i][j];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new BlockMask(getExtent(), cloned);
|
return new BlockMask(getExtent(), cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean test(BlockState block) {
|
|
||||||
long[] bitSet = bitSets[block.getInternalBlockTypeId()];
|
|
||||||
if (bitSet == null) return false;
|
|
||||||
if (bitSet.length == 0) return true;
|
|
||||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
}
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
BlockStateHolder block = getExtent().getBlock(vector);
|
|
||||||
long[] bitSet = bitSets[block.getInternalBlockTypeId()];
|
|
||||||
if (bitSet == null) return false;
|
|
||||||
if (bitSet.length == 0) return true;
|
|
||||||
return FastBitSet.get(bitSet, block.getInternalPropertiesId());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public Mask2D toMask2D() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
@ -30,6 +30,8 @@ public class BlockMaskBuilder {
|
|||||||
private static final Operator LESS_EQUAL = (a, b) -> a <= b;
|
private static final Operator LESS_EQUAL = (a, b) -> a <= b;
|
||||||
private static final Operator NOT = (a, b) -> a != b;
|
private static final Operator NOT = (a, b) -> a != b;
|
||||||
|
|
||||||
|
private final static long[] ALL = new long[0];
|
||||||
|
|
||||||
private interface Operator {
|
private interface Operator {
|
||||||
boolean test(int left, int right);
|
boolean test(int left, int right);
|
||||||
}
|
}
|
||||||
@ -222,7 +224,7 @@ public class BlockMaskBuilder {
|
|||||||
if (states == null) return false;
|
if (states == null) return false;
|
||||||
List values = prop.getValues();
|
List values = prop.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
return (states == BlockMask.ALL || FastBitSet.get(states, localI));
|
return (states == ALL || FastBitSet.get(states, localI));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
|
private void suggest(String input, String property, Collection<BlockType> finalTypes) throws InputParseException {
|
||||||
@ -239,6 +241,7 @@ public class BlockMaskBuilder {
|
|||||||
///// end internal /////
|
///// end internal /////
|
||||||
|
|
||||||
private long[][] bitSets;
|
private long[][] bitSets;
|
||||||
|
private boolean[] ordinals;
|
||||||
|
|
||||||
private boolean optimizedStates = true;
|
private boolean optimizedStates = true;
|
||||||
|
|
||||||
@ -257,23 +260,24 @@ public class BlockMaskBuilder {
|
|||||||
this.bitSets = bitSets;
|
this.bitSets = bitSets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder parse(String input) {
|
public BlockMaskBuilder addAll() {
|
||||||
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
|
bitSets[i] = ALL;
|
||||||
|
}
|
||||||
|
reset(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder addAll() {
|
private void reset(boolean optimized) {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
this.ordinals = null;
|
||||||
bitSets[i] = BlockMask.ALL;
|
this.optimizedStates = optimized;
|
||||||
}
|
|
||||||
optimizedStates = true;
|
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder clear() {
|
public BlockMaskBuilder clear() {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
bitSets[i] = null;
|
bitSets[i] = null;
|
||||||
}
|
}
|
||||||
optimizedStates = true;
|
reset(true);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -287,13 +291,13 @@ public class BlockMaskBuilder {
|
|||||||
int i = type.getInternalId();
|
int i = type.getInternalId();
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states != null) {
|
if (states != null) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
Arrays.fill(states, -1);
|
Arrays.fill(states, -1);
|
||||||
}
|
}
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
FastBitSet.clear(states, stateId);
|
FastBitSet.clear(states, stateId);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -315,7 +319,7 @@ public class BlockMaskBuilder {
|
|||||||
if (states != null) {
|
if (states != null) {
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
boolean set = true;
|
boolean set = true;
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
} else {
|
} else {
|
||||||
set = FastBitSet.get(states, stateId);
|
set = FastBitSet.get(states, stateId);
|
||||||
@ -325,7 +329,7 @@ public class BlockMaskBuilder {
|
|||||||
FastBitSet.set(states, stateId);
|
FastBitSet.set(states, stateId);
|
||||||
else
|
else
|
||||||
bitSets[i] = null;
|
bitSets[i] = null;
|
||||||
optimizedStates = true;
|
reset(true);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -354,14 +358,14 @@ public class BlockMaskBuilder {
|
|||||||
List values = prop.getValues();
|
List values = prop.getValues();
|
||||||
for (int j = 0; j < values.size(); j++) {
|
for (int j = 0; j < values.size(); j++) {
|
||||||
int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = j << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
if (states == BlockMask.ALL || FastBitSet.get(states, localI)) {
|
if (states == ALL || FastBitSet.get(states, localI)) {
|
||||||
if (!allowed.test(type, new AbstractMap.SimpleEntry(prop, values.get(j)))) {
|
if (!allowed.test(type, new AbstractMap.SimpleEntry(prop, values.get(j)))) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
FastBitSet.setAll(states);
|
FastBitSet.setAll(states);
|
||||||
}
|
}
|
||||||
FastBitSet.clear(states, localI);
|
FastBitSet.clear(states, localI);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -371,7 +375,7 @@ public class BlockMaskBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public BlockMaskBuilder add(BlockType type) {
|
public BlockMaskBuilder add(BlockType type) {
|
||||||
bitSets[type.getInternalId()] = BlockMask.ALL;
|
bitSets[type.getInternalId()] = ALL;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,13 +383,13 @@ public class BlockMaskBuilder {
|
|||||||
BlockType type = state.getBlockType();
|
BlockType type = state.getBlockType();
|
||||||
int i = type.getInternalId();
|
int i = type.getInternalId();
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states != BlockMask.ALL) {
|
if (states != ALL) {
|
||||||
if (states == null) {
|
if (states == null) {
|
||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
int stateId = state.getInternalPropertiesId();
|
int stateId = state.getInternalPropertiesId();
|
||||||
FastBitSet.set(states, stateId);
|
FastBitSet.set(states, stateId);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -414,7 +418,7 @@ public class BlockMaskBuilder {
|
|||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
if (allow.test(type)) {
|
if (allow.test(type)) {
|
||||||
bitSets[i] = BlockMask.ALL;
|
bitSets[i] = ALL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
@ -423,7 +427,7 @@ public class BlockMaskBuilder {
|
|||||||
public BlockMaskBuilder addAll(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate) {
|
public BlockMaskBuilder addAll(Predicate<BlockType> typePredicate, BiPredicate<BlockType, Map.Entry<Property<?>, ?>> propPredicate) {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
long[] states = bitSets[i];
|
long[] states = bitSets[i];
|
||||||
if (states == BlockMask.ALL) continue;
|
if (states == ALL) continue;
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
if (!typePredicate.test(type)) {
|
if (!typePredicate.test(type)) {
|
||||||
continue;
|
continue;
|
||||||
@ -438,7 +442,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[i] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
FastBitSet.set(states, localI);
|
FastBitSet.set(states, localI);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -450,7 +454,7 @@ public class BlockMaskBuilder {
|
|||||||
public BlockMaskBuilder add(BlockType type, Property property, int index) {
|
public BlockMaskBuilder add(BlockType type, Property property, int index) {
|
||||||
AbstractProperty prop = (AbstractProperty) property;
|
AbstractProperty prop = (AbstractProperty) property;
|
||||||
long[] states = bitSets[type.getInternalId()];
|
long[] states = bitSets[type.getInternalId()];
|
||||||
if (states == BlockMask.ALL) return this;
|
if (states == ALL) return this;
|
||||||
|
|
||||||
List values = property.getValues();
|
List values = property.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
@ -459,7 +463,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
}
|
}
|
||||||
set(type, states, property, index);
|
set(type, states, property, index);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -470,13 +474,13 @@ public class BlockMaskBuilder {
|
|||||||
if (states == null) return this;
|
if (states == null) return this;
|
||||||
List values = property.getValues();
|
List values = property.getValues();
|
||||||
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
int localI = index << prop.getBitOffset() >> BlockTypes.BIT_OFFSET;
|
||||||
if (states == BlockMask.ALL || FastBitSet.get(states, localI)) {
|
if (states == ALL || FastBitSet.get(states, localI)) {
|
||||||
if (states == BlockMask.ALL) {
|
if (states == ALL) {
|
||||||
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
bitSets[type.getInternalId()] = states = FastBitSet.create(type.getMaxStateId() + 1);
|
||||||
FastBitSet.setAll(states);
|
FastBitSet.setAll(states);
|
||||||
}
|
}
|
||||||
clear(type, states, property, index);
|
clear(type, states, property, index);
|
||||||
optimizedStates = false;
|
reset(false);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
@ -522,7 +526,7 @@ public class BlockMaskBuilder {
|
|||||||
if (!optimizedStates) {
|
if (!optimizedStates) {
|
||||||
for (int i = 0; i < bitSets.length; i++) {
|
for (int i = 0; i < bitSets.length; i++) {
|
||||||
long[] bitSet = bitSets[i];
|
long[] bitSet = bitSets[i];
|
||||||
if (bitSet == null || bitSet == BlockMask.ALL) continue;
|
if (bitSet == null || bitSet == ALL) continue;
|
||||||
BlockType type = BlockTypes.get(i);
|
BlockType type = BlockTypes.get(i);
|
||||||
int maxStateId = type.getMaxStateId();
|
int maxStateId = type.getMaxStateId();
|
||||||
if (maxStateId == 0) {
|
if (maxStateId == 0) {
|
||||||
@ -530,7 +534,7 @@ public class BlockMaskBuilder {
|
|||||||
bitSets[i] = null;
|
bitSets[i] = null;
|
||||||
continue;
|
continue;
|
||||||
} else {
|
} else {
|
||||||
bitSets[i] = BlockMask.ALL;
|
bitSets[i] = ALL;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -545,19 +549,38 @@ public class BlockMaskBuilder {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set == 0) bitSets[i] = null;
|
if (set == 0) bitSets[i] = null;
|
||||||
else if (clear == 0) bitSets[i] = BlockMask.ALL;
|
else if (clear == 0) bitSets[i] = ALL;
|
||||||
}
|
}
|
||||||
optimizedStates = true;
|
reset(true);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected long[][] getBits() {
|
private boolean[] getOrdinals() {
|
||||||
return this.bitSets;
|
if (ordinals == null) {
|
||||||
|
ordinals = new boolean[BlockTypes.states.length];
|
||||||
|
for (int i = 0; i < BlockTypes.values.length; i++) {
|
||||||
|
long[] bitSet = bitSets[i];
|
||||||
|
if (bitSet == null) continue;
|
||||||
|
BlockType type = BlockTypes.values[i];
|
||||||
|
if (bitSet == ALL) {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (BlockState state : type.getAllStates()) {
|
||||||
|
if (FastBitSet.get(bitSet, state.getInternalPropertiesId())) {
|
||||||
|
ordinals[state.getOrdinal()] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ordinals;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockMask build(Extent extent) {
|
public BlockMask build(Extent extent) {
|
||||||
optimize();
|
return new BlockMask(extent, getOrdinals());
|
||||||
return new BlockMask(extent, bitSets);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.sk89q.worldedit.blocks.Blocks;
|
import com.sk89q.worldedit.blocks.Blocks;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
@ -30,6 +31,7 @@ import com.sk89q.worldedit.world.block.BlockType;
|
|||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class BlockStateMask extends AbstractExtentMask {
|
public class BlockStateMask extends AbstractExtentMask {
|
||||||
|
|
||||||
private final Map<String, String> states;
|
private final Map<String, String> states;
|
||||||
@ -52,7 +54,10 @@ public class BlockStateMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
BlockState block = getExtent().getBlock(vector);
|
return test(vector.getBlock(getExtent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean test(BlockState block) {
|
||||||
final Map<Property<Object>, Object> checkProps = cache
|
final Map<Property<Object>, Object> checkProps = cache
|
||||||
.computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b)));
|
.computeIfAbsent(block.getBlockType(), (b -> Blocks.resolveProperties(states, b)));
|
||||||
if (strict && checkProps.isEmpty()) {
|
if (strict && checkProps.isEmpty()) {
|
||||||
|
@ -1,20 +1,18 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.world.block.BlockType;
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
@Deprecated
|
||||||
public class BlockTypeMask extends AbstractExtentMask {
|
public class BlockTypeMask extends AbstractExtentMask {
|
||||||
private final boolean[] types;
|
private final boolean[] types;
|
||||||
|
|
||||||
@ -80,11 +78,12 @@ public class BlockTypeMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return types[getExtent().getBlockType(vector).getInternalId()];
|
return test(vector.getBlock(getExtent()).getBlockType());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean test(BlockType block) {
|
||||||
|
return types[block.getInternalId()];
|
||||||
}
|
}
|
||||||
// public boolean test(BlockVector3 vector) {
|
|
||||||
// return blocks.contains(getExtent().getBlock(vector).getBlockType());
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class ExistingBlockMask extends AbstractExtentMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
return !getExtent().getBlock(vector).getBlockType().getMaterial().isAir();
|
return !vector.getBlock(getExtent()).getMaterial().isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.internal.expression.Expression;
|
import com.sk89q.worldedit.internal.expression.Expression;
|
||||||
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
import com.sk89q.worldedit.internal.expression.ExpressionException;
|
||||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
public class InverseMask extends AbstractMask {
|
public class InverseMask extends AbstractMask {
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class InverseSingleBlockStateMask extends ABlockMask {
|
||||||
|
private final char ordinal;
|
||||||
|
|
||||||
|
public BlockStateHolder getBlockState() {
|
||||||
|
return BlockState.getFromOrdinal(ordinal);
|
||||||
|
}
|
||||||
|
|
||||||
|
public InverseSingleBlockStateMask(Extent extent, BlockState state) {
|
||||||
|
super(extent);
|
||||||
|
this.ordinal = state.getOrdinalChar();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(BlockVector3 vector) {
|
||||||
|
return ordinal != vector.getOrdinal(getExtent());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean test(BlockState state) {
|
||||||
|
return state.getOrdinalChar() != ordinal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask inverse() {
|
||||||
|
return new SingleBlockStateMask(getExtent(), BlockState.getFromOrdinal(ordinal));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,37 @@
|
|||||||
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
|
import com.sk89q.worldedit.extent.Extent;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockType;
|
||||||
|
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||||
|
|
||||||
|
public class InverseSingleBlockTypeMask extends ABlockMask {
|
||||||
|
private final int internalId;
|
||||||
|
|
||||||
|
public InverseSingleBlockTypeMask(Extent extent, BlockType type) {
|
||||||
|
super(extent);
|
||||||
|
this.internalId = type.getInternalId();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean test(BlockVector3 vector) {
|
||||||
|
return test(vector.getBlock(getExtent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final boolean test(BlockState state) {
|
||||||
|
return state.getBlockType().getInternalId() != internalId;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Mask inverse() {
|
||||||
|
return new SingleBlockTypeMask(getExtent(), BlockTypes.values[internalId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockType getBlockType() {
|
||||||
|
return BlockTypes.get(internalId);
|
||||||
|
}
|
||||||
|
}
|
@ -43,8 +43,6 @@ public interface Mask {
|
|||||||
*/
|
*/
|
||||||
boolean test(BlockVector3 vector);
|
boolean test(BlockVector3 vector);
|
||||||
|
|
||||||
// boolean test(FilterBlock block);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the 2D version of this mask if one exists.
|
* Get the 2D version of this mask if one exists.
|
||||||
*
|
*
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
@ -168,10 +169,6 @@ public class MaskIntersection extends AbstractMask {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 vector) {
|
||||||
if (masks.isEmpty()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Mask mask : masksArray) {
|
for (Mask mask : masksArray) {
|
||||||
if (!mask.test(vector)) {
|
if (!mask.test(vector)) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
package com.sk89q.worldedit.function.mask;
|
package com.sk89q.worldedit.function.mask;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
@ -52,7 +53,6 @@ public final class Masks {
|
|||||||
* @param finalMask the mask
|
* @param finalMask the mask
|
||||||
* @return a new mask
|
* @return a new mask
|
||||||
*/
|
*/
|
||||||
//<<<<<<< HEAD
|
|
||||||
public static Mask negate(final Mask finalMask) {
|
public static Mask negate(final Mask finalMask) {
|
||||||
return finalMask.inverse();
|
return finalMask.inverse();
|
||||||
}
|
}
|
||||||
@ -124,7 +124,7 @@ public final class Masks {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Mask or(Mask other) {
|
public Mask or(Mask other) {
|
||||||
return other;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,9 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
import static com.google.common.base.Preconditions.checkArgument;
|
import static com.google.common.base.Preconditions.checkArgument;
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.math.MutableVector3;
|
||||||
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
import com.sk89q.worldedit.math.noise.NoiseGenerator;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
@ -85,8 +87,8 @@ public class NoiseFilter extends AbstractMask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean test(BlockVector3 vector) {
|
public boolean test(BlockVector3 v) {
|
||||||
return noiseGenerator.noise(vector.toVector3()) <= density;
|
return noiseGenerator.noise(MutableVector3.get(v.getX(), v.getY(), v.getZ())) <= density;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -2,6 +2,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
@ -21,6 +21,7 @@ package com.sk89q.worldedit.function.mask;
|
|||||||
|
|
||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
|
import com.boydti.fawe.beta.FilterBlock;
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
import com.sk89q.worldedit.regions.Region;
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
package com.sk89q.worldedit.function.mask;
|
|
||||||
|
|
||||||
import com.sk89q.worldedit.extent.Extent;
|
|
||||||
import com.sk89q.worldedit.math.BlockVector3;
|
|
||||||
|
|
||||||
public class SingleBlockStateBitMask extends AbstractExtentMask {
|
|
||||||
private final int bitMask;
|
|
||||||
|
|
||||||
protected SingleBlockStateBitMask(Extent extent, int bitMask) {
|
|
||||||
super(extent);
|
|
||||||
this.bitMask = bitMask;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean test(BlockVector3 vector) {
|
|
||||||
int internalId = getExtent().getBlock(vector).getInternalId();
|
|
||||||
return (internalId & bitMask) == internalId;
|
|
||||||
}
|
|
||||||
}
|
|
Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren