Search in sources :

Example 1 with BlockType

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();
}
Also used : BlockType(com.sk89q.worldedit.world.block.BlockType)

Example 2 with BlockType

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();
}
Also used : BlockType(com.sk89q.worldedit.world.block.BlockType) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock)

Example 3 with BlockType

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());
}
Also used : BlockState(com.sk89q.worldedit.world.block.BlockState) BlockType(com.sk89q.worldedit.world.block.BlockType)

Example 4 with BlockType

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;
}
Also used : BlockType(com.sk89q.worldedit.world.block.BlockType) BlockVector3(com.sk89q.worldedit.math.BlockVector3) Vector3(com.sk89q.worldedit.math.Vector3) MutableVector3(com.fastasyncworldedit.core.math.MutableVector3)

Example 5 with BlockType

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();
}
Also used : TextureUtil(com.fastasyncworldedit.core.util.TextureUtil) BlockType(com.sk89q.worldedit.world.block.BlockType)

Aggregations

BlockType (com.sk89q.worldedit.world.block.BlockType)63 BlockState (com.sk89q.worldedit.world.block.BlockState)20 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)18 Map (java.util.Map)12 HashMap (java.util.HashMap)9 BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)8 ArrayList (java.util.ArrayList)8 TextureUtil (com.fastasyncworldedit.core.util.TextureUtil)7 World (com.sk89q.worldedit.world.World)7 List (java.util.List)7 CompoundTag (com.sk89q.jnbt.CompoundTag)5 Tag (com.sk89q.jnbt.Tag)5 EditSession (com.sk89q.worldedit.EditSession)5 Property (com.sk89q.worldedit.registry.state.Property)5 Direction (com.sk89q.worldedit.util.Direction)5 IOException (java.io.IOException)5 Locale (java.util.Locale)5 Set (java.util.Set)5 MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)4 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)4