Search in sources :

Example 1 with RoundedTransform

use of com.fastasyncworldedit.core.math.transform.RoundedTransform in project FastAsyncWorldEdit by IntellectualSites.

the class ClipboardSpline method pasteBlocks.

@Override
protected int pasteBlocks(BlockVector3 target, Vector3 offset, double angle) throws MaxChangedBlocksException {
    RoundedTransform transform = new RoundedTransform(new AffineTransform().translate(offset).rotateY(angle));
    if (!this.transform.isIdentity()) {
        transform = transform.combine(this.transform);
    }
    if (!originalTransform.isIdentity()) {
        transform = transform.combine(originalTransform);
    }
    // Pasting
    Clipboard clipboard = clipboardHolder.getClipboard();
    clipboard.setOrigin(center.subtract(centerOffset).round());
    clipboardHolder.setTransform(transform);
    BlockVector3 functionOffset = target.subtract(clipboard.getOrigin());
    final int offX = functionOffset.getBlockX();
    final int offY = functionOffset.getBlockY();
    final int offZ = functionOffset.getBlockZ();
    Operation operation = clipboardHolder.createPaste(editSession).to(target).ignoreAirBlocks(true).filter(v -> buffer.add(v.getBlockX() + offX, v.getBlockY() + offY, v.getBlockZ() + offZ)).build();
    Operations.completeLegacy(operation);
    // Cleanup
    clipboardHolder.setTransform(originalTransform);
    clipboard.setOrigin(originalOrigin);
    return operation instanceof ForwardExtentCopy ? ((ForwardExtentCopy) operation).getAffected() : 0;
}
Also used : EditSession(com.sk89q.worldedit.EditSession) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) BlockVector3(com.sk89q.worldedit.math.BlockVector3) ClipboardHolder(com.sk89q.worldedit.session.ClipboardHolder) RoundedTransform(com.fastasyncworldedit.core.math.transform.RoundedTransform) MaxChangedBlocksException(com.sk89q.worldedit.MaxChangedBlocksException) Interpolation(com.sk89q.worldedit.math.interpolation.Interpolation) AffineTransform(com.sk89q.worldedit.math.transform.AffineTransform) LocalBlockVectorSet(com.fastasyncworldedit.core.math.LocalBlockVectorSet) ForwardExtentCopy(com.sk89q.worldedit.function.operation.ForwardExtentCopy) Transform(com.sk89q.worldedit.math.transform.Transform) Vector3(com.sk89q.worldedit.math.Vector3) Operations(com.sk89q.worldedit.function.operation.Operations) Operation(com.sk89q.worldedit.function.operation.Operation) Region(com.sk89q.worldedit.regions.Region) AffineTransform(com.sk89q.worldedit.math.transform.AffineTransform) RoundedTransform(com.fastasyncworldedit.core.math.transform.RoundedTransform) Clipboard(com.sk89q.worldedit.extent.clipboard.Clipboard) Operation(com.sk89q.worldedit.function.operation.Operation) BlockVector3(com.sk89q.worldedit.math.BlockVector3) ForwardExtentCopy(com.sk89q.worldedit.function.operation.ForwardExtentCopy)

Aggregations

LocalBlockVectorSet (com.fastasyncworldedit.core.math.LocalBlockVectorSet)1 RoundedTransform (com.fastasyncworldedit.core.math.transform.RoundedTransform)1 EditSession (com.sk89q.worldedit.EditSession)1 MaxChangedBlocksException (com.sk89q.worldedit.MaxChangedBlocksException)1 Clipboard (com.sk89q.worldedit.extent.clipboard.Clipboard)1 ForwardExtentCopy (com.sk89q.worldedit.function.operation.ForwardExtentCopy)1 Operation (com.sk89q.worldedit.function.operation.Operation)1 Operations (com.sk89q.worldedit.function.operation.Operations)1 BlockVector3 (com.sk89q.worldedit.math.BlockVector3)1 Vector3 (com.sk89q.worldedit.math.Vector3)1 Interpolation (com.sk89q.worldedit.math.interpolation.Interpolation)1 AffineTransform (com.sk89q.worldedit.math.transform.AffineTransform)1 Transform (com.sk89q.worldedit.math.transform.Transform)1 Region (com.sk89q.worldedit.regions.Region)1 ClipboardHolder (com.sk89q.worldedit.session.ClipboardHolder)1