mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2025-07-01 02:46:41 +00:00
.
This commit is contained in:
@ -6,6 +6,8 @@ import com.boydti.fawe.jnbt.anvil.BitArray4096;
|
||||
import com.boydti.fawe.object.collection.IterableThreadLocal;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
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.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
@ -33,6 +35,10 @@ public class FaweCache implements Trimable {
|
||||
BLOCK_STATES.clean();
|
||||
SECTION_BLOCKS.clean();
|
||||
PALETTE_CACHE.clean();
|
||||
PALETTE_TO_BLOCK_CHAR.clean();
|
||||
|
||||
MUTABLE_VECTOR3.clean();
|
||||
MUTABLE_BLOCKVECTOR3.clean();
|
||||
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
|
||||
*/
|
||||
|
@ -2,13 +2,11 @@ package com.boydti.fawe.beta;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
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.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public class ArrayFilterBlock extends SimpleFilterBlock {
|
||||
private final char[] blocks;
|
||||
@ -42,7 +40,7 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(BlockState state) {
|
||||
public void setBlock(BlockState state) {
|
||||
blocks[index] = state.getOrdinalChar();
|
||||
}
|
||||
|
||||
@ -57,20 +55,23 @@ public class ArrayFilterBlock extends SimpleFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getState() {
|
||||
public BlockState getBlock() {
|
||||
return BlockTypes.states[ordinal];
|
||||
}
|
||||
|
||||
@Override
|
||||
public BaseBlock getBaseBlock() {
|
||||
return getState().toBaseBlock();
|
||||
public BaseBlock getFullBlock() {
|
||||
return getBlock().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CompoundTag getTag() {
|
||||
public CompoundTag getNbtData() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNbtData(@Nullable CompoundTag nbtData) {}
|
||||
|
||||
@Override
|
||||
public int getX() {
|
||||
return x;
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.beta;
|
||||
|
||||
import com.boydti.fawe.beta.implementation.blocks.CharGetBlocks;
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.regions.Region;
|
||||
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
|
||||
public void setOrdinal(final int ordinal) {
|
||||
delegate.set(this, (char) ordinal);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setState(final BlockState state) {
|
||||
public void setBlock(final BlockState state) {
|
||||
delegate.set(this, state.getOrdinalChar());
|
||||
}
|
||||
|
||||
@ -235,28 +241,81 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BlockState getState() {
|
||||
public final BlockState getBlock() {
|
||||
final int ordinal = getArr[index];
|
||||
return BlockTypes.states[ordinal];
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BaseBlock getBaseBlock() {
|
||||
final BlockState state = getState();
|
||||
public final BaseBlock getFullBlock() {
|
||||
final BlockState state = getBlock();
|
||||
final BlockMaterial material = state.getMaterial();
|
||||
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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final CompoundTag getTag() {
|
||||
public final CompoundTag getNbtData() {
|
||||
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) {
|
||||
return states[getArr[index - 256]];
|
||||
}
|
||||
@ -268,7 +327,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
return BlockTypes.__RESERVED__.getDefaultState();
|
||||
}
|
||||
|
||||
public final BlockState getStateAbove() {
|
||||
@Override
|
||||
public final BlockState getBlockAbove() {
|
||||
if (y < 16) {
|
||||
return states[getArr[index + 256]];
|
||||
}
|
||||
@ -280,7 +340,8 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
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 layerAdd = newY >> 4;
|
||||
switch (layerAdd) {
|
||||
@ -334,135 +395,34 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
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;
|
||||
if (newX >> 4 == 0 && newZ >> 4 == 0) {
|
||||
final int newY = this.y + y;
|
||||
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();
|
||||
|
||||
|
||||
@Override
|
||||
public BlockVector3 north() {
|
||||
return this.north;
|
||||
}
|
||||
|
||||
public final BaseBlock getFullBlockRelative(final int x, final int y, final int z) {
|
||||
final int newX = this.x + x;
|
||||
final int newZ = this.z + z;
|
||||
if (newX >> 4 == 0 && newZ >> 4 == 0) {
|
||||
final int newY = this.y + y;
|
||||
final int layerAdd = newY >> 4;
|
||||
BlockState state = BlockTypes.__RESERVED__.getDefaultState();
|
||||
switch (layerAdd) {
|
||||
case 0:
|
||||
state = states[getArr[this.index + ((y << 8) + (z << 4) + x)]];
|
||||
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 < 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();
|
||||
@Override
|
||||
public BlockVector3 east() {
|
||||
return super.east();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 south() {
|
||||
return super.south();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockVector3 west() {
|
||||
return super.west();
|
||||
}
|
||||
|
||||
/*
|
||||
Extent
|
||||
*/
|
||||
@Override
|
||||
public char getOrdinalChar(Extent orDefault) {
|
||||
return getOrdinalChar();
|
||||
}
|
||||
|
||||
/*
|
||||
@ -484,7 +444,7 @@ public class CharFilterBlock extends ChunkFilterBlock {
|
||||
@Override
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
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);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import com.sk89q.worldedit.regions.Region;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class ChunkFilterBlock extends FilterBlock {
|
||||
public abstract class ChunkFilterBlock extends SimpleFilterBlock {
|
||||
public ChunkFilterBlock(Extent 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;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
import com.sk89q.worldedit.blocks.TileEntityBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
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.BlockState;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
public abstract class FilterBlock extends BlockVector3 implements Extent {
|
||||
private final Extent extent;
|
||||
import static com.sk89q.worldedit.world.block.BlockTypes.states;
|
||||
|
||||
public FilterBlock(Extent extent) {
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
public final Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
public abstract class FilterBlock extends BlockVector3 implements Extent, TileEntityBlock {
|
||||
public abstract Extent getExtent();
|
||||
|
||||
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 void setBiome(BiomeType biome) {
|
||||
setBiome(getX(), getY(), getZ(), biome);
|
||||
}
|
||||
|
||||
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
|
||||
public BlockVector3 getMinimumPoint() {
|
||||
@ -46,32 +51,40 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return getStateRelative(x - getX(), y - getY(), z - getZ());
|
||||
return getExtent().getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
return getStateRelative(0, -1, 0);
|
||||
public BlockState getBlockBelow() {
|
||||
return getBlock(getX(), getY() - 1, getZ());
|
||||
}
|
||||
|
||||
public BlockState getStateAbove() {
|
||||
return getStateRelative(0, 1, 0);
|
||||
public BlockState getBlockAbove() {
|
||||
return getBlock(getX(), getY() + 1, getZ());
|
||||
}
|
||||
|
||||
public BlockState getStateRelativeY(final int y) {
|
||||
return getStateRelative(0, y, 0);
|
||||
public BlockState getBlockNorth() {
|
||||
return getBlock(getX(), getY(), getZ() - 1);
|
||||
}
|
||||
|
||||
public BlockState getStateRelative(final int x, final int y, final int z) {
|
||||
return getFullBlockRelative(x, y, z).toBlockState();
|
||||
public BlockState getBlockEast() {
|
||||
return getBlock(getX() + 1, getY(), getZ());
|
||||
}
|
||||
|
||||
public BaseBlock getFullBlockRelative(int x, int y, int z) {
|
||||
return getExtent().getFullBlock(x + getX(), y + getY(), z + getZ());
|
||||
public BlockState getBlockSouth() {
|
||||
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
|
||||
@ -102,4 +115,56 @@ public abstract class FilterBlock extends BlockVector3 implements Extent {
|
||||
public int getChunkZ() {
|
||||
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 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);
|
||||
|
||||
|
@ -2,10 +2,12 @@ package com.boydti.fawe.beta;
|
||||
|
||||
import com.sk89q.jnbt.CompoundTag;
|
||||
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.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
@ -16,7 +18,7 @@ import java.util.UUID;
|
||||
* Interface for setting blocks
|
||||
*/
|
||||
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);
|
||||
|
||||
@ -42,4 +44,10 @@ public interface IChunkSet extends IBlocks, OutputExtent {
|
||||
|
||||
@Override
|
||||
void reset();
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
default Operation commit() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void flood(Flood flood, FilterBlockMask mask, FilterBlock block) {
|
||||
default void flood(Flood flood, FilterBlockMask mask, ChunkFilterBlock block) {
|
||||
getParent().flood(flood, mask, block);
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ public interface IDelegateChunk<U extends IChunk> extends IChunk {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void filter(Filter filter, FilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
|
||||
getParent().filter(filter, block, region, unitialized, unitialized2);
|
||||
default void filterBlocks(Filter filter, ChunkFilterBlock block, @Nullable Region region, MutableBlockVector3 unitialized, MutableBlockVector3 unitialized2) {
|
||||
getParent().filterBlocks(filter, block, region, unitialized, unitialized2);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -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;
|
||||
|
||||
public abstract class SimpleFilterBlock extends FilterBlock {
|
||||
private final Extent extent;
|
||||
|
||||
public SimpleFilterBlock(Extent extent) {
|
||||
super(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;
|
||||
this.extent = extent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOrdinal() {
|
||||
return ordinal;
|
||||
}
|
||||
|
||||
@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;
|
||||
public final Extent getExtent() {
|
||||
return extent;
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
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.beta.ChunkFilterBlock;
|
||||
import com.boydti.fawe.beta.Filter;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
import com.boydti.fawe.beta.IQueueExtent;
|
||||
import com.boydti.fawe.beta.Trimable;
|
||||
@ -186,7 +185,7 @@ public abstract class QueueHandler implements Trimable, Runnable {
|
||||
if (newChunk != null) {
|
||||
chunk = newChunk;
|
||||
if (block == null) block = queue.initFilterBlock();
|
||||
chunk.filter(newFilter, block, region, mbv1, mbv2);
|
||||
chunk.filterBlocks(newFilter, block, region, mbv1, mbv2);
|
||||
}
|
||||
queue.submit(chunk);
|
||||
}
|
||||
|
@ -1,11 +1,12 @@
|
||||
package com.boydti.fawe.beta.implementation;
|
||||
|
||||
import com.boydti.fawe.beta.CharFilterBlock;
|
||||
import com.boydti.fawe.beta.ChunkFilterBlock;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
|
||||
public abstract class SimpleCharQueueExtent extends SingleThreadQueueExtent {
|
||||
@Override
|
||||
public FilterBlock initFilterBlock() {
|
||||
public ChunkFilterBlock initFilterBlock() {
|
||||
return new CharFilterBlock(this);
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public abstract class ChunkHolder implements IChunk, Supplier<IChunkGet> {
|
||||
}
|
||||
|
||||
@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 IChunkSet set = getOrCreateSet();
|
||||
try {
|
||||
|
@ -1,10 +1,16 @@
|
||||
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.FilterBlockMask;
|
||||
import com.boydti.fawe.beta.Flood;
|
||||
import com.boydti.fawe.beta.IChunk;
|
||||
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
|
||||
|
@ -2,6 +2,7 @@ package com.boydti.fawe.command;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.FaweAPI;
|
||||
import com.boydti.fawe.beta.SingleFilterBlock;
|
||||
import com.boydti.fawe.config.BBC;
|
||||
import com.boydti.fawe.config.Commands;
|
||||
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.RunnableVal;
|
||||
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.FilteredTextureUtil;
|
||||
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.io.ClipboardFormats;
|
||||
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.math.BlockVector3;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
@ -70,7 +69,6 @@ import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.Function;
|
||||
|
||||
import static com.boydti.fawe.util.image.ImageUtil.load;
|
||||
@ -419,9 +417,7 @@ public class CFICommands extends MethodCommands {
|
||||
}
|
||||
default: {
|
||||
blocks = new HashSet<>();
|
||||
BlockPattern pattern = new BlockPattern(BlockTypes.AIR.getDefaultState());
|
||||
PatternExtent extent = new PatternExtent(pattern);
|
||||
|
||||
SingleFilterBlock extent = new SingleFilterBlock();
|
||||
ParserContext parserContext = new ParserContext();
|
||||
parserContext.setActor(player);
|
||||
parserContext.setWorld(player.getWorld());
|
||||
@ -432,9 +428,10 @@ public class CFICommands extends MethodCommands {
|
||||
TextureUtil tu = Fawe.get().getTextureUtil();
|
||||
for (int typeId : tu.getValidBlockIds()) {
|
||||
BlockType type = BlockTypes.get(typeId);
|
||||
BlockStateHolder block = type.getDefaultState();
|
||||
pattern.setBlock(block);
|
||||
if (mask.test(BlockVector3.ZERO)) blocks.add(type);
|
||||
extent.init(0, 0, 0, type.getDefaultState().toBaseBlock());
|
||||
if (mask.test(extent)) {
|
||||
blocks.add(type);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -104,7 +104,7 @@ public class MCAWorld implements SimpleWorld {
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return extent.getLazyBlock(position);
|
||||
return extent.getBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -150,7 +150,7 @@ public class CavesGen extends GenBase {
|
||||
for (int local_z = i3; (!waterFound) && (local_z < i4); local_z++) {
|
||||
for (int local_y = i2 + 1; (!waterFound) && (local_y >= i1 - 1); local_y--) {
|
||||
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) {
|
||||
waterFound = true;
|
||||
}
|
||||
@ -174,8 +174,8 @@ public class CavesGen extends GenBase {
|
||||
for (int local_y = i2; local_y > i1; local_y--) {
|
||||
double d11 = ((local_y - 1) + 0.5D - y) / d4;
|
||||
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 materialAbove = chunk.getLazyBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||
BlockStateHolder material = chunk.getBlock(bx + local_x, local_y, bz + local_z);
|
||||
BlockStateHolder materialAbove = chunk.getBlock(bx + local_x, local_y + 1, bz + local_z);
|
||||
BlockType blockType = material.getBlockType();
|
||||
switch (blockType.getInternalId()) {
|
||||
case BlockID.MYCELIUM:
|
||||
@ -192,7 +192,7 @@ public class CavesGen extends GenBase {
|
||||
// If grass was just deleted, try to
|
||||
// move it down
|
||||
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) {
|
||||
chunk.setBlock(bx + local_x, local_y - 1, bz + local_z, BlockTypes.STONE.getDefaultState());
|
||||
}
|
||||
|
@ -1,15 +1,14 @@
|
||||
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.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.function.pattern.AbstractPattern;
|
||||
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.BlockTypes;
|
||||
|
||||
public class DataAnglePattern extends AbstractPattern {
|
||||
public final double FACTOR;
|
||||
@ -24,7 +23,7 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
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 y = vector.getBlockY();
|
||||
int z = vector.getBlockZ();
|
||||
@ -32,7 +31,6 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
return -1;
|
||||
}
|
||||
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, 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;
|
||||
@ -42,8 +40,8 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockStateHolder block = extent.getBlock(position);
|
||||
int slope = getSlope(block, position);
|
||||
BlockState block = extent.getBlock(position);
|
||||
int slope = getSlope(block, position, extent);
|
||||
if (slope == -1) return block.toBaseBlock();
|
||||
int data = (Math.min(slope, 255)) >> 4;
|
||||
return block.withPropertyId(data).toBaseBlock();
|
||||
@ -52,7 +50,7 @@ public class DataAnglePattern extends AbstractPattern {
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockStateHolder block = extent.getBlock(getPosition);
|
||||
int slope = getSlope(block, getPosition);
|
||||
int slope = getSlope(block, getPosition, extent);
|
||||
if (slope == -1) return false;
|
||||
int data = (Math.min(slope, 255)) >> 4;
|
||||
return extent.setBlock(setPosition, block.withPropertyId(data));
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.brush;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.object.FaweQueue;
|
||||
import com.boydti.fawe.object.collection.BlockVectorSet;
|
||||
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.MaxChangedBlocksException;
|
||||
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.Mask;
|
||||
import com.sk89q.worldedit.function.mask.SolidBlockMask;
|
||||
@ -34,7 +36,7 @@ public class LayerBrush implements Brush {
|
||||
@Override
|
||||
public void build(EditSession editSession, BlockVector3 position, Pattern ignore, double size) throws MaxChangedBlocksException {
|
||||
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 RadiusMask radius = new RadiusMask(0, (int) size);
|
||||
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));
|
||||
Operations.completeBlindly(visitor);
|
||||
BlockVectorSet visited = visitor.getVisited();
|
||||
BlockStateHolder firstPattern = layers[0];
|
||||
visitor = new RecursiveVisitor((Mask) pos -> {
|
||||
int depth = visitor.getDepth() + 1;
|
||||
if (depth > 1) {
|
||||
boolean found = false;
|
||||
int previous = layers[depth - 1].getInternalId();
|
||||
int previous2 = layers[depth - 2].getInternalId();
|
||||
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
||||
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
||||
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()) == previous2) {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
return false;
|
||||
visitor = new RecursiveVisitor(new Mask() {
|
||||
@Override
|
||||
public boolean test(BlockVector3 pos) {
|
||||
int depth = visitor.getDepth() + 1;
|
||||
if (depth > 1) {
|
||||
boolean found = false;
|
||||
int previous = layers[depth - 1].getInternalId();
|
||||
int previous2 = layers[depth - 2].getInternalId();
|
||||
for (BlockVector3 dir : BreadthFirstSearch.DEFAULT_DIRECTIONS) {
|
||||
mutable.setComponents(pos.getBlockX() + dir.getBlockX(), pos.getBlockY() + dir.getBlockY(), pos.getBlockZ() + dir.getBlockZ());
|
||||
if (visitor.isVisited(mutable) && queue.getCachedCombinedId4Data(mutable.getBlockX(), mutable.getBlockY(), mutable.getBlockZ()) == previous) {
|
||||
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()) == previous2) {
|
||||
found = true;
|
||||
break;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!found) {
|
||||
return false;
|
||||
}
|
||||
return !adjacent.test(pos);
|
||||
}
|
||||
return !adjacent.test(pos);
|
||||
}, pos -> {
|
||||
int depth = visitor.getDepth();
|
||||
BlockStateHolder currentPattern = layers[depth];
|
||||
|
@ -79,7 +79,7 @@ public class EmptyClipboard implements Clipboard {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return EditSession.nullBlock;
|
||||
}
|
||||
|
||||
|
@ -52,17 +52,12 @@ public class BlockTranslateExtent extends AbstractDelegateExtent {
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 location) {
|
||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 location) {
|
||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return super.getLazyBlock(x + dx, y + dy, z + dz);
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return super.getBlock(x + dx, y + dy, z + dz);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -50,7 +50,7 @@ public class EmptyExtent implements Extent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
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 {
|
||||
return setBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ(), block);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
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
|
||||
public BlockState getLazyBlock(BlockVector3 location) {
|
||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
public BlockState getBlock(BlockVector3 location) {
|
||||
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@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);
|
||||
BlockType type = BlockTypes.getFromStateId(combinedId4Data);
|
||||
BlockState state = type.withStateId(combinedId4Data);
|
||||
@ -157,11 +155,6 @@ public class FastWorldEditExtent extends AbstractDelegateExtent implements HasFa
|
||||
return world.getEntities(region);
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(final BlockVector3 position) {
|
||||
return this.getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(final BlockVector2 position, final BiomeType biome) {
|
||||
queue.setBiome(position.getBlockX(), position.getBlockZ(), biome);
|
||||
|
@ -66,7 +66,7 @@ public class NullExtent extends FaweRegionExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(final BlockVector3 arg0) {
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
if(reason != null) {
|
||||
throw new FaweException(reason);
|
||||
}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
|
||||
public boolean setBiome(final BlockVector2 arg0, final BiomeType arg1) {
|
||||
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
|
||||
public Entity createEntity(final Location arg0, final BaseEntity arg1) {
|
||||
if(reason != null) {
|
||||
|
@ -47,20 +47,15 @@ public class PositionTransformExtent extends ResettableExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return super.getLazyBlock(getPos(BlockVector3.at(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
return super.getLazyBlock(getPos(position));
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
return super.getBlock(getPos(BlockVector3.at(x, y, z)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getBlock(BlockVector3 position) {
|
||||
return super.getBlock(getPos(position));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return super.getFullBlock(getPos(position));
|
||||
|
@ -63,12 +63,12 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
if (!limit.MAX_CHECKS()) {
|
||||
WEManager.IMP.cancelEditSafe(this, BBC.WORLDEDIT_CANCEL_REASON_MAX_CHECKS);
|
||||
return EditSession.nullBlock;
|
||||
} else {
|
||||
return extent.getLazyBlock(x, y, z);
|
||||
return extent.getBlock(x, y, z);
|
||||
}
|
||||
}
|
||||
|
||||
@ -88,8 +88,8 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 location) {
|
||||
return getLazyBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
public BlockState getBlock(BlockVector3 location) {
|
||||
return getBlock(location.getBlockX(), location.getBlockY(), location.getBlockZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,19 +58,11 @@ public class TemporalExtent extends AbstractDelegateExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(BlockVector3 position) {
|
||||
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) {
|
||||
public BlockState getBlock(int x, int y, int z) {
|
||||
if (this.x == x && this.y == y && this.z == z) {
|
||||
return block.toImmutableState();
|
||||
}
|
||||
return super.getLazyBlock(x, y, z);
|
||||
return super.getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,6 +1,7 @@
|
||||
package com.boydti.fawe.object.extent;
|
||||
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.math.Vector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -14,7 +15,8 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
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 int maxy;
|
||||
|
||||
@ -53,56 +55,45 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
if (min == null) {
|
||||
min = pos;
|
||||
}
|
||||
mutable.mutX(((pos.getX() - min.getX())));
|
||||
mutable.mutY(((pos.getY() - min.getY())));
|
||||
mutable.mutZ(((pos.getZ() - min.getZ())));
|
||||
MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
|
||||
tmp.mutX((tmp.getX() + min.getX()));
|
||||
tmp.mutY((tmp.getY() + min.getY()));
|
||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
||||
return tmp.toBlockPoint();
|
||||
mutable1.mutX(((pos.getX() - min.getX())));
|
||||
mutable1.mutY(((pos.getY() - min.getY())));
|
||||
mutable1.mutZ(((pos.getZ() - min.getZ())));
|
||||
Vector3 tmp = getTransform().apply(mutable1);
|
||||
mutable2.mutX((tmp.getX() + min.getX()));
|
||||
mutable2.mutY((tmp.getY() + min.getY()));
|
||||
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
||||
return mutable2;
|
||||
}
|
||||
|
||||
public BlockVector3 getPos(int x, int y, int z) {
|
||||
if (min == null) {
|
||||
min = BlockVector3.at(x, y, z);
|
||||
}
|
||||
mutable.mutX(((x - min.getX())));
|
||||
mutable.mutY(((y - min.getY())));
|
||||
mutable.mutZ(((z - min.getZ())));
|
||||
MutableVector3 tmp = new MutableVector3(getTransform().apply(mutable.toVector3()));
|
||||
tmp.mutX((tmp.getX() + min.getX()));
|
||||
tmp.mutY((tmp.getY() + min.getY()));
|
||||
tmp.mutZ((tmp.getZ() + min.getZ()));
|
||||
mutable1.mutX(((x - min.getX())));
|
||||
mutable1.mutY(((y - min.getY())));
|
||||
mutable1.mutZ(((z - min.getZ())));
|
||||
Vector3 tmp = getTransform().apply(mutable1);
|
||||
mutable2.mutX((tmp.getX() + min.getX()));
|
||||
mutable2.mutY((tmp.getY() + min.getY()));
|
||||
mutable2.mutZ((tmp.getZ() + min.getZ()));
|
||||
return tmp.toBlockPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockState getLazyBlock(int x, int y, int z) {
|
||||
return transform(super.getLazyBlock(getPos(x, y, z)));
|
||||
public BlockState getBlock(int x, int y, int 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
|
||||
public BaseBlock getFullBlock(BlockVector3 position) {
|
||||
return transform(super.getFullBlock(getPos(position)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public BiomeType getBiome(BlockVector2 position) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
return super.getBiome(getPos(mutable).toBlockVector2());
|
||||
public BiomeType getBiome(int x, int z) {
|
||||
BlockVector3 p = getPos(x, 0, z);
|
||||
return super.getBiome(p.getX(), p.getZ());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -117,10 +108,8 @@ public class TransformExtent extends BlockTransformExtent {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setBiome(BlockVector2 position, BiomeType biome) {
|
||||
mutable.mutX(position.getBlockX());
|
||||
mutable.mutZ(position.getBlockZ());
|
||||
mutable.mutY(0);
|
||||
return super.setBiome(getPos(mutable).toBlockVector2(), biome);
|
||||
public boolean setBiome(int x, int y, int z, BiomeType biome) {
|
||||
BlockVector3 p = getPos(x, y, z);
|
||||
return super.setBiome(p.getX(), p.getY(), p.getZ(), biome);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
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.Mask;
|
||||
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) {
|
||||
Extent extent = getExtent();
|
||||
if (data != -1) {
|
||||
return extent.getLazyBlock(vector).getInternalPropertiesId() == data;
|
||||
return extent.getBlock(vector).getInternalPropertiesId() == data;
|
||||
} else {
|
||||
data = extent.getLazyBlock(vector).getInternalPropertiesId();
|
||||
data = extent.getBlock(vector).getInternalPropertiesId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ public class IdDataMask extends AbstractExtentMask implements ResettableMask {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
if (combined != -1) {
|
||||
return extent.getLazyBlock(vector).getInternalId() == combined;
|
||||
return extent.getBlock(vector).getInternalId() == combined;
|
||||
} else {
|
||||
combined = extent.getLazyBlock(vector).getInternalId();
|
||||
combined = extent.getBlock(vector).getInternalId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ public class IdMask extends AbstractExtentMask implements ResettableMask {
|
||||
public boolean test(BlockVector3 vector) {
|
||||
Extent extent = getExtent();
|
||||
if (id != -1) {
|
||||
return extent.getLazyBlock(vector).getInternalBlockTypeId() == id;
|
||||
return extent.getBlock(vector).getInternalBlockTypeId() == id;
|
||||
} else {
|
||||
id = extent.getLazyBlock(vector).getInternalBlockTypeId();
|
||||
id = extent.getBlock(vector).getInternalBlockTypeId();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -7,11 +7,8 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class SurfaceMask extends AdjacentAnyMask {
|
||||
private final transient Extent extent;
|
||||
|
||||
public SurfaceMask(Extent extent) {
|
||||
super(getMask(extent));
|
||||
this.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.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
@ -1,11 +1,8 @@
|
||||
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.object.DataAnglePattern;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
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.BlockType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class AngleColorPattern extends DataAnglePattern {
|
||||
protected transient TextureUtil util;
|
||||
protected transient TextureHolder holder;
|
||||
|
||||
public AngleColorPattern(Extent extent, TextureHolder holder, int distance) {
|
||||
super(extent, distance);
|
||||
this.util = holder.getTextureUtil();
|
||||
this.holder = holder.getTextureUtil();
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@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
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BaseBlock block = extent.getFullBlock(position);
|
||||
int slope = getSlope(block, position);
|
||||
int slope = getSlope(block, position, extent);
|
||||
if (slope == -1) return block;
|
||||
int color = util.getColor(block.getBlockType());
|
||||
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||
if (color == 0) return block;
|
||||
int newColor = getColor(color, slope);
|
||||
return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||
return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSlope(BlockStateHolder block, BlockVector3 vector) {
|
||||
int slope = super.getSlope(block, vector);
|
||||
public int getSlope(BlockStateHolder block, BlockVector3 vector, Extent extent) {
|
||||
int slope = super.getSlope(block, vector, extent);
|
||||
if (slope != -1) {
|
||||
int x = vector.getBlockX();
|
||||
int y = vector.getBlockY();
|
||||
@ -76,15 +58,15 @@ public class AngleColorPattern extends DataAnglePattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockStateHolder block = extent.getBlock(getPosition);
|
||||
int slope = getSlope(block, getPosition);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
BlockStateHolder block = get.getBlock(extent);
|
||||
int slope = getSlope(block, get, extent);
|
||||
if (slope == -1) return false;
|
||||
int color = util.getColor(block.getBlockType());
|
||||
int color = holder.getTextureUtil().getColor(block.getBlockType());
|
||||
if (color == 0) return false;
|
||||
int newColor = getColor(color, slope);
|
||||
BlockType newBlock = util.getNearestBlock(newColor);
|
||||
BlockType newBlock = holder.getTextureUtil().getNearestBlock(newColor);
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
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.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
|
||||
public class AverageColorPattern extends AbstractExtentPattern {
|
||||
private transient TextureHolder holder;
|
||||
@ -35,19 +30,14 @@ public class AverageColorPattern extends AbstractExtentPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType blockType = extent.getBlockType(getPosition);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
BlockType blockType = get.getBlock(extent).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(blockType);
|
||||
if (currentColor == 0) return false;
|
||||
int newColor = util.averageColor(currentColor, color);
|
||||
BlockType newBlock = util.getNearestBlock(newColor);
|
||||
if (newBlock == blockType) return false;
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
return set.setBlock(extent, newBlock.getDefaultState());
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -10,7 +11,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
||||
import java.io.IOException;
|
||||
|
||||
public class BiomePattern extends ExistingPattern {
|
||||
private transient MutableBlockVector2 mutable = new MutableBlockVector2();
|
||||
private final BiomeType biome;
|
||||
|
||||
public BiomePattern(Extent extent, BiomeType biome) {
|
||||
@ -24,8 +24,8 @@ public class BiomePattern extends ExistingPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 getPosition) throws WorldEditException {
|
||||
return extent.setBiome(set.getBlockX(), set.getBlockY(), set.getBlockZ(), biome);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
return set.setBiome(extent, biome);
|
||||
}
|
||||
|
||||
public class BiomePatternException extends RuntimeException {
|
||||
@ -45,9 +45,4 @@ public class BiomePattern extends ExistingPattern {
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.object.FawePlayer;
|
||||
import com.boydti.fawe.object.collection.LocalBlockVectorSet;
|
||||
import com.boydti.fawe.util.FaweTimer;
|
||||
@ -17,17 +18,18 @@ import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BufferedPattern extends AbstractPattern implements ResettablePattern {
|
||||
protected transient LocalBlockVectorSet set = new LocalBlockVectorSet();
|
||||
protected transient FaweTimer timer;
|
||||
protected transient long[] actionTime;
|
||||
protected final LocalBlockVectorSet set = new LocalBlockVectorSet();
|
||||
protected final FaweTimer timer;
|
||||
protected final long[] actionTime;
|
||||
|
||||
protected final Pattern pattern;
|
||||
protected final UUID uuid;
|
||||
|
||||
public BufferedPattern(FawePlayer fp, Pattern parent) {
|
||||
this.uuid = fp.getUUID();
|
||||
this.actionTime = fp.getMeta("lastActionTime");
|
||||
if (actionTime == null) fp.setMeta("lastActionTime", actionTime = new long[2]);
|
||||
long[] tmp = fp.getMeta("lastActionTime");
|
||||
if (tmp == null) fp.setMeta("lastActionTime", tmp = new long[2]);
|
||||
actionTime = tmp;
|
||||
this.pattern = parent;
|
||||
this.timer = Fawe.get().getTimer();
|
||||
}
|
||||
@ -38,16 +40,12 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
long now = timer.getTick();
|
||||
try {
|
||||
if (!set(setPosition)) {
|
||||
return false;
|
||||
}
|
||||
return pattern.apply(extent, setPosition, getPosition);
|
||||
} catch (UnsupportedOperationException ignore) {
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
actionTime[1] = timer.getTick();
|
||||
if (!set(get)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
return pattern.apply(extent, get, set);
|
||||
}
|
||||
|
||||
public boolean set(BlockVector3 pos) {
|
||||
@ -63,17 +61,4 @@ public class BufferedPattern extends AbstractPattern implements ResettablePatter
|
||||
actionTime[1] = actionTime[0];
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.FaweCache;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
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.BlockTypes;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
@ -25,6 +25,24 @@ public class DataPattern extends AbstractExtentPattern {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BaseBlock oldBlock = getExtent().getFullBlock(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;
|
||||
|
||||
import com.boydti.fawe.Fawe;
|
||||
import com.boydti.fawe.util.TextureHolder;
|
||||
import com.boydti.fawe.util.TextureUtil;
|
||||
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.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class DesaturatePattern extends AbstractPattern {
|
||||
private transient TextureHolder holder;
|
||||
private final TextureHolder holder;
|
||||
private final Extent extent;
|
||||
private final double value;
|
||||
|
||||
@ -29,7 +24,11 @@ public class DesaturatePattern extends AbstractPattern {
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
BlockType block = extent.getBlockType(position);
|
||||
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 g = (color >> 8) & 0xFF;
|
||||
int b = (color >> 0) & 0xFF;
|
||||
@ -39,35 +38,22 @@ public class DesaturatePattern extends AbstractPattern {
|
||||
int green = (int) (g + value * (l - g));
|
||||
int blue = (int) (b + value * (l - b));
|
||||
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
|
||||
return util.getNearestBlock(newColor).getDefaultState().toBaseBlock();
|
||||
return newColor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType block = extent.getBlockType(getPosition);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
BlockType type = get.getBlock(extent).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int color = util.getColor(block);
|
||||
int r = (color >> 16) & 0xFF;
|
||||
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);
|
||||
int color = util.getColor(type);
|
||||
int newColor = getColor(color);
|
||||
if (newColor == color) {
|
||||
return false;
|
||||
}
|
||||
BlockType newBlock = util.getNextNearestBlock(newColor);
|
||||
if (block.equals(newBlock)) {
|
||||
BlockType newType = util.getNextNearestBlock(newColor);
|
||||
if (type.equals(newType)) {
|
||||
return false;
|
||||
}
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
return set.setBlock(extent, newType.getDefaultState());
|
||||
}
|
||||
}
|
@ -1,12 +1,10 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
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.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
public class ExistingPattern extends AbstractExtentPattern {
|
||||
public ExistingPattern(Extent extent) {
|
||||
@ -19,10 +17,10 @@ public class ExistingPattern extends AbstractExtentPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
if (set.equals(get)) {
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
if (set == get || set.equals(get)) {
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.EditSession;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -23,9 +24,7 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
* greater than {@code 0}.</p>
|
||||
*/
|
||||
public class ExpressionPattern extends AbstractPattern {
|
||||
|
||||
public String input;
|
||||
private transient Expression expression;
|
||||
private final Expression expression;
|
||||
|
||||
/**
|
||||
* Create a new instance.
|
||||
@ -35,7 +34,6 @@ public class ExpressionPattern extends AbstractPattern {
|
||||
*/
|
||||
public ExpressionPattern(String input) throws ExpressionException {
|
||||
checkNotNull(input);
|
||||
this.input = input;
|
||||
this.expression = Expression.compile(input, "x", "y", "z");
|
||||
}
|
||||
|
||||
@ -65,13 +63,4 @@ public class ExpressionPattern extends AbstractPattern {
|
||||
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
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
Region region = clipboard.getRegion();
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, setPosition);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
ForwardExtentCopy copy = new ForwardExtentCopy(clipboard, clipboard.getRegion(), clipboard.getOrigin(), extent, set);
|
||||
copy.setSourceMask(new ExistingBlockMask(clipboard));
|
||||
Operations.completeBlindly(copy);
|
||||
return true;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -27,11 +28,11 @@ public class Linear2DBlockPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@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;
|
||||
if (index < 0) {
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -27,11 +28,11 @@ public class Linear3DBlockPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@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;
|
||||
if (index < 0) {
|
||||
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
|
||||
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) {
|
||||
index = 0;
|
||||
}
|
||||
return patternsArray[index++].apply(extent, set, get);
|
||||
return patternsArray[index++].apply(extent, get, set);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -12,32 +14,30 @@ import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
|
||||
public class MaskedPattern extends AbstractPattern {
|
||||
|
||||
private final PatternExtent patternExtent;
|
||||
private final Pattern secondaryPattern;
|
||||
private final Pattern primary;
|
||||
private final Pattern secondary;
|
||||
private Mask mask;
|
||||
|
||||
public MaskedPattern(Mask mask, PatternExtent primary, Pattern secondary) {
|
||||
public MaskedPattern(Mask mask, Pattern primary, Pattern secondary) {
|
||||
this.mask = mask;
|
||||
this.patternExtent = primary;
|
||||
this.secondaryPattern = secondary;
|
||||
this.primary = primary;
|
||||
this.secondary = secondary;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
patternExtent.setTarget(position);
|
||||
if (mask.test(position)) {
|
||||
return patternExtent.getAndResetTarget().toBaseBlock();
|
||||
return primary.apply(position);
|
||||
}
|
||||
return secondaryPattern.apply(position);
|
||||
return secondary.apply(position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
patternExtent.setTarget(get);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.beta.DelegateFilterBlock;
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -15,7 +17,7 @@ import java.io.IOException;
|
||||
public class NoXPattern extends AbstractPattern {
|
||||
|
||||
private final Pattern pattern;
|
||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public NoXPattern(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
@ -23,21 +25,15 @@ public class NoXPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 pos) {
|
||||
// mutable.mutY((pos.getY()));
|
||||
// mutable.mutZ((pos.getZ()));
|
||||
// return pattern.apply(mutable);
|
||||
return pattern.apply(pos);
|
||||
mutable.mutY((pos.getY()));
|
||||
mutable.mutZ((pos.getZ()));
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
// mutable.mutY((get.getY()));
|
||||
// mutable.mutZ((get.getZ()));
|
||||
return pattern.apply(extent, set, get);
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
// mutable = new MutableBlockVector3();
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutY((get.getY()));
|
||||
mutable.mutZ((get.getZ()));
|
||||
return pattern.apply(extent, mutable, set);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -15,29 +17,23 @@ import java.io.IOException;
|
||||
public class NoYPattern extends AbstractPattern {
|
||||
|
||||
private final Pattern pattern;
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public NoYPattern(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 pos) {
|
||||
// mutable.mutX((pos.getX()));
|
||||
// mutable.mutZ((pos.getZ()));
|
||||
return pattern.apply(pos);
|
||||
mutable.mutX((pos.getX()));
|
||||
mutable.mutZ((pos.getZ()));
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
// mutable.mutX((get.getX()));
|
||||
// mutable.mutZ((get.getZ()));
|
||||
return pattern.apply(extent, set, get);
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
// mutable = new MutableBlockVector3();
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutX((get.getX()));
|
||||
mutable.mutZ((get.getZ()));
|
||||
return pattern.apply(extent, mutable, set);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
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.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -20,24 +22,19 @@ public class NoZPattern extends AbstractPattern {
|
||||
this.pattern = pattern;
|
||||
}
|
||||
|
||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 pos) {
|
||||
// mutable.mutX((pos.getX()));
|
||||
// mutable.mutY((pos.getY()));
|
||||
return pattern.apply(pos);
|
||||
mutable.mutX((pos.getX()));
|
||||
mutable.mutY((pos.getY()));
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
// mutable.mutX((get.getX()));
|
||||
// mutable.mutY((get.getY()));
|
||||
return pattern.apply(extent, set, get);
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
// mutable = new MutableBlockVector3();
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutX((get.getX()));
|
||||
mutable.mutY((get.getY()));
|
||||
return pattern.apply(extent, mutable, set);
|
||||
}
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
@ -15,7 +16,7 @@ import java.io.IOException;
|
||||
public class OffsetPattern extends AbstractPattern {
|
||||
|
||||
private final int dx, dy, dz;
|
||||
// private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private final Pattern pattern;
|
||||
|
||||
public OffsetPattern(Pattern pattern, int dx, int dy, int dz) {
|
||||
@ -27,24 +28,17 @@ public class OffsetPattern extends AbstractPattern {
|
||||
|
||||
@Override
|
||||
public BaseBlock apply(BlockVector3 position) {
|
||||
// mutable.mutX((position.getX() + dx));
|
||||
// mutable.mutY((position.getY() + dy));
|
||||
// mutable.mutZ((position.getZ() + dz));
|
||||
// return pattern.apply(mutable);
|
||||
return pattern.apply(BlockVector3.at(position.getX() + dx, position.getY() + dy, position.getZ() + dz));
|
||||
mutable.mutX((position.getX() + dx));
|
||||
mutable.mutY((position.getY() + dy));
|
||||
mutable.mutZ((position.getZ() + dz));
|
||||
return pattern.apply(mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
// mutable.mutX((get.getX() + dx));
|
||||
// mutable.mutY((get.getY() + dy));
|
||||
// mutable.mutZ((get.getZ() + dz));
|
||||
// return pattern.apply(extent, set, 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();
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutX((get.getX() + dx));
|
||||
mutable.mutY((get.getY() + dy));
|
||||
mutable.mutZ((get.getZ() + dz));
|
||||
return pattern.apply(extent, get, mutable);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.boydti.fawe.object.string.MutableCharSequence;
|
||||
import com.boydti.fawe.util.MathMan;
|
||||
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.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 com.sk89q.worldedit.world.block.BlockTypes;
|
||||
|
||||
@ -211,11 +211,11 @@ public class PropertyPattern extends AbstractExtentPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
BaseBlock block = getExtent().getFullBlock(get);
|
||||
block = apply(block, null);
|
||||
if (block != null) {
|
||||
return extent.setBlock(set, block);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
int ordinal = get.getOrdinal(extent);
|
||||
int newOrdinal = transformed[ordinal];
|
||||
if (newOrdinal != ordinal) {
|
||||
set.setOrdinal(extent, newOrdinal);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@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()));
|
||||
AffineTransform transform = new AffineTransform();
|
||||
if (randomRotate) {
|
||||
@ -55,9 +55,9 @@ public class RandomFullClipboardPattern extends AbstractPattern {
|
||||
Schematic schematic = new Schematic(clipboard);
|
||||
Transform newTransform = holder.getTransform();
|
||||
if (newTransform.isIdentity()) {
|
||||
schematic.paste(extent, setPosition, false);
|
||||
schematic.paste(extent, set, false);
|
||||
} else {
|
||||
schematic.paste(extent, setPosition, false, newTransform);
|
||||
schematic.paste(extent, set, false, newTransform);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -40,19 +41,10 @@ public class RandomOffsetPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
|
||||
mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
|
||||
mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
|
||||
return pattern.apply(extent, set, 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();
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
|
||||
mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
|
||||
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
|
||||
return pattern.apply(extent, get, mutable);
|
||||
}
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
package com.boydti.fawe.object.pattern;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.extent.Extent;
|
||||
@ -13,8 +14,8 @@ import java.io.IOException;
|
||||
public class RelativePattern extends AbstractPattern implements ResettablePattern {
|
||||
|
||||
private final Pattern pattern;
|
||||
private transient BlockVector3 origin;
|
||||
private transient MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
private BlockVector3 origin;
|
||||
private final MutableBlockVector3 mutable = new MutableBlockVector3();
|
||||
|
||||
public RelativePattern(Pattern pattern) {
|
||||
this.pattern = pattern;
|
||||
@ -32,19 +33,14 @@ public class RelativePattern extends AbstractPattern implements ResettablePatter
|
||||
}
|
||||
|
||||
@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) {
|
||||
origin = get;
|
||||
origin = set;
|
||||
}
|
||||
mutable.mutX((get.getX() - origin.getX()));
|
||||
mutable.mutY((get.getY() - origin.getY()));
|
||||
mutable.mutZ((get.getZ() - origin.getZ()));
|
||||
return pattern.apply(extent, set, mutable);
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
mutable = new MutableBlockVector3();
|
||||
mutable.mutX((set.getX() - origin.getX()));
|
||||
mutable.mutY((set.getY() - origin.getY()));
|
||||
mutable.mutZ((set.getZ() - origin.getZ()));
|
||||
return pattern.apply(extent, get, mutable);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -1,22 +1,19 @@
|
||||
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.TextureUtil;
|
||||
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.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.io.IOException;
|
||||
|
||||
public class SaturatePattern extends AbstractPattern {
|
||||
private transient TextureHolder holder;
|
||||
private final TextureHolder holder;
|
||||
private final int color;
|
||||
private final Extent extent;
|
||||
|
||||
@ -37,19 +34,14 @@ public class SaturatePattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 setPosition, BlockVector3 getPosition) throws WorldEditException {
|
||||
BlockType block = extent.getBlockType(getPosition);
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
BlockType block = get.getBlock(extent).getBlockType();
|
||||
TextureUtil util = holder.getTextureUtil();
|
||||
int currentColor = util.getColor(block);
|
||||
if (currentColor == 0) return false;
|
||||
int newColor = util.multiplyColor(currentColor, color);
|
||||
BlockType newBlock = util.getNearestBlock(newColor);
|
||||
if (newBlock.equals(block)) return false;
|
||||
return extent.setBlock(setPosition, newBlock.getDefaultState());
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
holder = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
return set.setBlock(extent, newBlock.getDefaultState());
|
||||
}
|
||||
}
|
@ -1,22 +1,19 @@
|
||||
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.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.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||
import com.sk89q.worldedit.world.block.BlockType;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
public class ShadePattern extends AbstractPattern {
|
||||
private transient TextureUtil util;
|
||||
private final TextureUtil util;
|
||||
private final Extent extent;
|
||||
private final boolean darken;
|
||||
|
||||
@ -33,8 +30,13 @@ public class ShadePattern extends AbstractPattern {
|
||||
return (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block)).getDefaultState().toBaseBlock();
|
||||
}
|
||||
|
||||
private void readObject(java.io.ObjectInputStream stream) throws IOException, ClassNotFoundException {
|
||||
stream.defaultReadObject();
|
||||
util = Fawe.get().getCachedTextureUtil(true, 0, 100);
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
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;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.WorldEditException;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
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.MutableBlockVector3;
|
||||
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.util.SplittableRandom;
|
||||
@ -17,25 +20,27 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
||||
private final int dx, dy, dz;
|
||||
private final Pattern pattern;
|
||||
|
||||
private transient int dx2, dy2, dz2;
|
||||
private transient MutableBlockVector3 mutable;
|
||||
private transient boolean[] solid;
|
||||
private final int dx2, dy2, dz2;
|
||||
private final MutableBlockVector3 mutable;
|
||||
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) {
|
||||
this.pattern = pattern;
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.dz = dz;
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
this.dx2 = dx * 2 + 1;
|
||||
this.dy2 = dy * 2 + 1;
|
||||
this.dz2 = dz * 2 + 1;
|
||||
solid = SolidBlockMask.getTypes();
|
||||
this.r = new SplittableRandom();
|
||||
this.mutable = new MutableBlockVector3();
|
||||
}
|
||||
@ -46,7 +51,7 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
||||
mutable.mutY((position.getY() + r.nextInt(dy2) - dy));
|
||||
mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz));
|
||||
BaseBlock block = pattern.apply(mutable);
|
||||
if (solid[block.getInternalBlockTypeId()]) {
|
||||
if (block.getMaterial().isSolid()) {
|
||||
return block;
|
||||
} else {
|
||||
return pattern.apply(position);
|
||||
@ -54,20 +59,15 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Extent extent, BlockVector3 set, BlockVector3 get) throws WorldEditException {
|
||||
mutable.mutX((get.getX() + r.nextInt(dx2) - dx));
|
||||
mutable.mutY((get.getY() + r.nextInt(dy2) - dy));
|
||||
mutable.mutZ((get.getZ() + r.nextInt(dz2) - dz));
|
||||
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
|
||||
mutable.mutX((set.getX() + r.nextInt(dx2) - dx));
|
||||
mutable.mutY((set.getY() + r.nextInt(dy2) - dy));
|
||||
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
|
||||
BlockStateHolder block = pattern.apply(mutable);
|
||||
if (solid[block.getInternalBlockTypeId()]) {
|
||||
return pattern.apply(extent, set, mutable);
|
||||
if (block.getMaterial().isSolid()) {
|
||||
return pattern.apply(extent, get, mutable);
|
||||
} 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;
|
||||
|
||||
import com.boydti.fawe.beta.FilterBlock;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.function.pattern.AbstractPattern;
|
||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||
@ -13,20 +14,16 @@ import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
||||
private final Pattern pattern;
|
||||
private int moves;
|
||||
private final int moves;
|
||||
|
||||
private transient MutableBlockVector3 cur;
|
||||
private transient MutableBlockVector3[] buffer;
|
||||
private transient MutableBlockVector3[] allowed;
|
||||
private transient MutableBlockVector3 next;
|
||||
private final MutableBlockVector3 cur;
|
||||
private final MutableBlockVector3[] buffer;
|
||||
private final MutableBlockVector3[] allowed;
|
||||
private MutableBlockVector3 next;
|
||||
|
||||
public SurfaceRandomOffsetPattern(Pattern pattern, int distance) {
|
||||
this.pattern = pattern;
|
||||
this.moves = Math.min(255, distance);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
cur = new MutableBlockVector3();
|
||||
this.buffer = new MutableBlockVector3[BreadthFirstSearch.DIAGONAL_DIRECTIONS.length];
|
||||
for (int i = 0; i < buffer.length; i++) {
|
||||
@ -110,9 +107,4 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
|
||||
BlockStateHolder block = pattern.apply(v);
|
||||
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
|
||||
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
|
||||
|
@ -61,8 +61,8 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getLazyBlock(int x, int y, int z) {
|
||||
return getQueue().getLazyBlock(x, y, z);
|
||||
default BlockState getBlock(int x, int y, int z) {
|
||||
return getQueue().getBlock(x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -453,11 +453,6 @@ public interface IDelegateFaweQueue extends FaweQueue {
|
||||
return getQueue().createEntity(location, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
default BlockState getLazyBlock(BlockVector3 position) {
|
||||
return getQueue().getLazyBlock(position);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
default Operation commit() {
|
||||
|
@ -1,25 +1,18 @@
|
||||
package com.boydti.fawe.util;
|
||||
|
||||
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.object.pattern.PatternExtent;
|
||||
import com.boydti.fawe.util.image.ImageUtil;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
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.function.mask.Mask;
|
||||
import com.sk89q.worldedit.function.pattern.BlockPattern;
|
||||
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.BlockTypes;
|
||||
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.Int2ObjectOpenHashMap;
|
||||
import it.unimi.dsi.fastutil.ints.IntArraySet;
|
||||
@ -27,12 +20,23 @@ import it.unimi.dsi.fastutil.longs.LongArrayList;
|
||||
|
||||
import javax.imageio.ImageIO;
|
||||
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.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
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.regex.Pattern;
|
||||
import java.util.zip.ZipEntry;
|
||||
@ -61,14 +65,15 @@ public class TextureUtil implements TextureHolder {
|
||||
|
||||
public static TextureUtil fromMask(Mask mask) throws FileNotFoundException {
|
||||
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);
|
||||
|
||||
TextureUtil tu = Fawe.get().getTextureUtil();
|
||||
for (int typeId : tu.getValidBlockIds()) {
|
||||
BlockType block = BlockTypes.get(typeId);
|
||||
pattern.setBlock(block.getDefaultState());
|
||||
if (mask.test(BlockVector3.ZERO)) {
|
||||
extent.init(0, 0, 0, block.getDefaultState().toBaseBlock());
|
||||
if (mask.test(extent)) {
|
||||
blocks.add(block);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user