use of com.sk89q.worldedit.world.block.BlockType in project FastAsyncWorldEdit by IntellectualSites.
the class ShadePattern method applyBlock.
@Override
public BaseBlock applyBlock(BlockVector3 position) {
BlockType block = extent.getBlock(position).getBlockType();
BlockType type;
if (block == BlockTypes.GRASS_BLOCK) {
int color = util.getColor(extent.getBiome(position));
type = (darken ? util.getDarkerBlock(color) : util.getLighterBlock(color));
} else {
type = (darken ? util.getDarkerBlock(block) : util.getLighterBlock(block));
}
return type.getDefaultState().toBaseBlock();
}
use of com.sk89q.worldedit.world.block.BlockType in project FastAsyncWorldEdit by IntellectualSites.
the class AngleColorPattern method applyBlock.
@Override
public BaseBlock applyBlock(BlockVector3 position) {
BaseBlock block = extent.getFullBlock(position);
int slope = getSlope(block, position, extent);
if (slope == -1) {
return block;
}
BlockType type = block.getBlockType();
int color;
if (type == BlockTypes.GRASS_BLOCK) {
color = holder.getTextureUtil().getColor(extent.getBiome(position));
} else {
color = holder.getTextureUtil().getColor(type);
}
if (color == 0) {
return block;
}
int newColor = getColor(color, slope);
return holder.getTextureUtil().getNearestBlock(newColor).getDefaultState().toBaseBlock();
}
use of com.sk89q.worldedit.world.block.BlockType in project FastAsyncWorldEdit by IntellectualSites.
the class AngleColorPattern method apply.
@Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
BlockState block = get.getBlock(extent);
int slope = getSlope(block, get, extent);
if (slope == -1) {
return false;
}
BlockType type = block.getBlockType();
int color;
if (type == BlockTypes.GRASS_BLOCK) {
color = holder.getTextureUtil().getColor(extent.getBiome(get));
} else {
color = holder.getTextureUtil().getColor(type);
}
if (color == 0) {
return false;
}
int newColor = getColor(color, slope);
BlockType newBlock = holder.getTextureUtil().getNearestBlock(newColor);
if (newBlock == null) {
return false;
}
return set.setBlock(extent, newBlock.getDefaultState());
}
use of com.sk89q.worldedit.world.block.BlockType in project FastAsyncWorldEdit by IntellectualSites.
the class ImageBrushMask method test.
@Override
public boolean test(BlockVector3 vector) {
if (solid.test(vector)) {
int dx = vector.getBlockX() - center.getBlockX();
int dy = vector.getBlockY() - center.getBlockY();
int dz = vector.getBlockZ() - center.getBlockZ();
Vector3 pos1 = transform.apply(mutable.setComponents(dx - 0.5, dy - 0.5, dz - 0.5));
int x1 = (int) (pos1.getX() * scale + centerImageX);
int z1 = (int) (pos1.getZ() * scale + centerImageZ);
Vector3 pos2 = transform.apply(mutable.setComponents(dx + 0.5, dy + 0.5, dz + 0.5));
int x2 = (int) (pos2.getX() * scale + centerImageX);
int z2 = (int) (pos2.getZ() * scale + centerImageZ);
if (x2 < x1) {
int tmp = x1;
x1 = x2;
x2 = tmp;
}
if (z2 < z1) {
int tmp = z1;
z1 = z2;
z2 = tmp;
}
if (x1 >= width || x2 < 0 || z1 >= height || z2 < 0) {
return false;
}
int color = colorFunction.call(x1, z1, x2, z2, session, vector);
if (color != 0) {
BlockType block = texture.getNearestBlock(color);
if (block != null) {
session.setBlock(vector, block.getDefaultState());
}
}
return true;
}
return false;
}
use of com.sk89q.worldedit.world.block.BlockType in project FastAsyncWorldEdit by IntellectualSites.
the class DesaturatePattern method applyBlock.
@Override
public BaseBlock applyBlock(BlockVector3 position) {
BlockType type = extent.getBlock(position).getBlockType();
TextureUtil util = holder.getTextureUtil();
int color;
if (type == BlockTypes.GRASS_BLOCK) {
color = holder.getTextureUtil().getColor(extent.getBiome(position));
} else {
color = holder.getTextureUtil().getColor(type);
}
return util.getNearestBlock(color).getDefaultState().toBaseBlock();
}
Aggregations