Search in sources :

Example 1 with BaseBlock

use of com.sk89q.worldedit.world.block.BaseBlock in project CoreProtect by PlayPro.

the class CoreProtectLogger method setBlock.

@Override
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 position, T block) throws WorldEditException {
    org.bukkit.World world = BukkitAdapter.adapt(eventWorld);
    if (!Config.getConfig(world).WORLDEDIT) {
        return eventExtent.setBlock(position, block);
    }
    BlockState oldBlock = eventExtent.getBlock(position);
    Material oldType = BukkitAdapter.adapt(oldBlock.getBlockType());
    Location location = new Location(world, position.getBlockX(), position.getBlockY(), position.getBlockZ());
    BaseBlock baseBlock = WorldEditLogger.getBaseBlock(eventExtent, position, location, oldType, oldBlock);
    // No clear way to get container content data from within the WorldEdit API
    // Data may be available by converting oldBlock.toBaseBlock().getNbtData()
    // e.g. BaseBlock block = eventWorld.getBlock(position);
    ItemStack[] containerData = Util.getContainerContents(oldType, null, location);
    if (eventExtent.setBlock(position, block)) {
        WorldEditLogger.postProcess(eventExtent, eventActor, position, location, block, baseBlock, oldType, oldBlock, containerData);
        return true;
    }
    return false;
}
Also used : BlockState(com.sk89q.worldedit.world.block.BlockState) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) BaseBlock(com.sk89q.worldedit.world.block.BaseBlock) Location(org.bukkit.Location)

Example 2 with BaseBlock

use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.

the class SolidRandomOffsetPattern method apply.

@Override
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);
    if (mutable.getY() < extent.getMinY() || mutable.getY() > extent.getMaxY()) {
        return false;
    }
    BaseBlock block = pattern.applyBlock(mutable);
    if (block.getMaterial().isSolid()) {
        return pattern.apply(extent, get, mutable);
    }
    return pattern.apply(extent, get, set);
}
Also used : BaseBlock(com.sk89q.worldedit.world.block.BaseBlock)

Example 3 with BaseBlock

use of com.sk89q.worldedit.world.block.BaseBlock 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 4 with BaseBlock

use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.

the class CombinedBlockCopy method apply.

@Override
public boolean apply(BlockVector3 position) throws WorldEditException {
    // BlockStateHolder block = source.getBlock(position);
    BaseBlock block = source.getFullBlock(position);
    function.apply(position);
    return destination.setBlock(position, block);
}
Also used : BaseBlock(com.sk89q.worldedit.world.block.BaseBlock)

Example 5 with BaseBlock

use of com.sk89q.worldedit.world.block.BaseBlock in project FastAsyncWorldEdit by IntellectualSites.

the class BlockReplacer method actSecondary.

@Override
public boolean actSecondary(Platform server, LocalConfiguration config, Player player, LocalSession session, Location clicked, @Nullable Direction face) {
    BaseBlock targetBlock = player.getWorld().getFullBlock(clicked.toVector().toBlockPoint());
    if (targetBlock != null) {
        pattern = targetBlock;
        player.print(Caption.of("worldedit.tool.repl.switched", targetBlock.getBlockType().getRichName()));
    }
    return true;
}
Also used : BaseBlock(com.sk89q.worldedit.world.block.BaseBlock)

Aggregations

BaseBlock (com.sk89q.worldedit.world.block.BaseBlock)50 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)22 BlockState (com.sk89q.worldedit.world.block.BlockState)10 CompoundTag (com.sk89q.jnbt.CompoundTag)9 HashMap (java.util.HashMap)7 Tag (com.sk89q.jnbt.Tag)6 Location (com.sk89q.worldedit.util.Location)6 World (com.sk89q.worldedit.world.World)6 BlockType (com.sk89q.worldedit.world.block.BlockType)6 IOException (java.io.IOException)6 MutableBlockVector3 (com.fastasyncworldedit.core.math.MutableBlockVector3)5 ListTag (com.sk89q.jnbt.ListTag)5 StringTag (com.sk89q.jnbt.StringTag)5 WorldEditException (com.sk89q.worldedit.WorldEditException)5 ArrayList (java.util.ArrayList)5 IntTag (com.sk89q.jnbt.IntTag)4 BaseEntity (com.sk89q.worldedit.entity.BaseEntity)4 CuboidRegion (com.sk89q.worldedit.regions.CuboidRegion)4 Region (com.sk89q.worldedit.regions.Region)4 NamedTag (com.sk89q.jnbt.NamedTag)3