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;
}
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);
}
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();
}
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);
}
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;
}
Aggregations