当前位置: 首页>>代码示例>>Java>>正文


Java Vector.subtract方法代码示例

本文整理汇总了Java中com.sk89q.worldedit.Vector.subtract方法的典型用法代码示例。如果您正苦于以下问题:Java Vector.subtract方法的具体用法?Java Vector.subtract怎么用?Java Vector.subtract使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.sk89q.worldedit.Vector的用法示例。


在下文中一共展示了Vector.subtract方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: build

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    int radius = (int) size;
    CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
    String replaced = command.replace("{x}", position.getBlockX() + "")
            .replace("{y}", Integer.toString(position.getBlockY()))
            .replace("{z}", Integer.toString(position.getBlockZ()))
            .replace("{world}", editSession.getQueue().getWorldName())
            .replace("{size}", Integer.toString(radius));

    FawePlayer fp = editSession.getPlayer();
    Player player = fp.getPlayer();
    WorldVectorFace face = player.getBlockTraceFace(256, true);
    if (face == null) {
        position = position.add(0, 1, 1);
    } else {
        position = face.getFaceVector();
    }
    fp.setSelection(selector);
    PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
    List<String> cmds = StringMan.split(replaced, ';');
    for (String cmd : cmds) {
        CommandEvent event = new CommandEvent(wePlayer, cmd);
        CommandManager.getInstance().handleCommandOnCurrentThread(event);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:27,代码来源:CommandBrush.java

示例2: pastePositionDirect

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/**
 * Paste structure at the provided position on the curve. The position will not be position-corrected
 * but will be passed directly to the interpolation algorithm.
 * @param position The position on the curve. Must be between 0.0 and 1.0 (both inclusive)
 * @return         The amount of blocks that have been changed
 * @throws MaxChangedBlocksException Thrown by WorldEdit if the limit of block changes for the {@link EditSession} has been reached
 */
public int pastePositionDirect(double position) throws MaxChangedBlocksException {
    Preconditions.checkArgument(position >= 0);
    Preconditions.checkArgument(position <= 1);

    // Calculate position from spline
    Vector target = interpolation.getPosition(position);
    Vector offset = target.subtract(target.round());
    target = target.subtract(offset);

    // Calculate rotation from spline

    Vector deriv = interpolation.get1stDerivative(position);
    Vector2D deriv2D = new Vector2D(deriv.getX(), deriv.getZ()).normalize();
    double angle = Math.toDegrees(
            Math.atan2(direction.getZ(), direction.getX()) - Math.atan2(deriv2D.getZ(), deriv2D.getX())
    );

    return pasteBlocks(target, offset, angle);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:27,代码来源:Spline.java

示例3: apply

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public void apply(EditSession editSession, LocalBlockVectorSet placed, Vector position, Pattern p, double size) throws MaxChangedBlocksException {
    int radius = getDistance();
    CuboidRegionSelector selector = new CuboidRegionSelector(editSession.getWorld(), position.subtract(radius, radius, radius), position.add(radius, radius, radius));
    String replaced = command.replace("{x}", position.getBlockX() + "")
            .replace("{y}", Integer.toString(position.getBlockY()))
            .replace("{z}", Integer.toString(position.getBlockZ()))
            .replace("{world}", editSession.getQueue().getWorldName())
            .replace("{size}", Integer.toString(radius));

    FawePlayer fp = editSession.getPlayer();
    Player player = fp.getPlayer();
    fp.setSelection(selector);
    PlayerWrapper wePlayer = new SilentPlayerWrapper(new LocationMaskedPlayerWrapper(player, new Location(player.getExtent(), position)));
    List<String> cmds = StringMan.split(replaced, ';');
    for (String cmd : cmds) {
        CommandEvent event = new CommandEvent(wePlayer, cmd);
        CommandManager.getInstance().handleCommandOnCurrentThread(event);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:ScatterCommand.java

示例4: getClipboard

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
public Clipboard getClipboard() throws IOException {
    try {
        addDimensionReaders();
        addBlockReaders();
        readFully();
        Vector min = new Vector(originX, originY, originZ);
        Vector offset = new Vector(offsetX, offsetY, offsetZ);
        Vector origin = min.subtract(offset);
        Vector dimensions = new Vector(width, height, length);
        fc.setDimensions(dimensions);
        CuboidRegion region = new CuboidRegion(min, min.add(width, height, length).subtract(Vector.ONE));
        clipboard.init(region, fc);
        clipboard.setOrigin(origin);
        return clipboard;
    } catch (Throwable e) {
        if (fc != null) {
            fc.close();
        }
        throw e;
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:22,代码来源:SchematicStreamer.java

示例5: toGlobal

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/** Converts the module's relative coordinates to global points (possible only after placement!)
 * @param relativePt A relative position, measured from the module origin, facing EAST.
 * @return 			 A global position, according to where and in which rotation this module was placed, null if called before placement.
 */
public Vector toGlobal(Vector relativePt) {
	if (placed) {
		Vector relPlusOff = relativePt.subtract(entry.placementLoc);
		Vector v_glob = Direc.rotatedBy(relPlusOff, turnedBy);       // rotate according to rotation of clipboard
		return v_glob.add(origin);
	}else {
		parent.setStateAndNotify(State.ERROR, "Module::toGlobal was called before placement!");
		return null; // will crash the plugin, above error message for debug
	}
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:15,代码来源:Module.java

示例6: toRelative

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/** Converts global world coordinates to the relative coordinate frame of this module, only valid after placement!
 * @param globalPt	A global world position.
 * @return			A relative position, measured from the module origin, facing EAST. Calculated according to placement and rotation.
 */
public Vector toRelative(Vector globalPt) {
	if (placed) {
		Vector globMinusOrig = globalPt.subtract(origin);
		// rotate back according to rotation of clipboard:
		Vector v_rel = new Vector(globMinusOrig);
		Direc.rotatedBy(v_rel, -turnedBy);
		return v_rel.add(entry.placementLoc);	
	}else {
		parent.setStateAndNotify(State.ERROR, "Module::toRelative was called before placement!");
		return null; // will crash the plugin, above error message for debug
	}
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:17,代码来源:Module.java

示例7: build

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    new MaskTraverser(mask).reset(editSession);
    SchemGen gen = new SchemGen(mask, editSession, editSession.getWorldData(), clipboards, randomRotate);
    CuboidRegion cuboid = new CuboidRegion(editSession.getWorld(), position.subtract(size, size, size), position.add(size, size, size));
    try {
        editSession.addSchems(cuboid, mask, editSession.getWorldData(), clipboards, rarity, randomRotate);
    } catch (WorldEditException e) {
        throw new RuntimeException(e);
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:12,代码来源:PopulateSchem.java

示例8: pasteBlocks

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
protected int pasteBlocks(Vector target, Vector 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);

    Vector 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, editSession.getWorldData())
            .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;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:37,代码来源:ClipboardSpline.java

示例9: apply

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public boolean apply(Vector position) throws WorldEditException {
    BaseBlock block = source.getBlock(position);
    Vector orig = position.subtract(from);
    Vector transformed = transform.apply(orig);

    // Apply transformations to NBT data if necessary
    block = transformNbtData(block);

    return destination.setBlock(transformed.add(to), block);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:12,代码来源:ExtentBlockCopy.java

示例10: selectSecondary

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public boolean selectSecondary(Vector position, SelectorLimits limits) {
    if (!started) {
        return false;
    }

    final Vector diff = position.subtract(region.getCenter());
    final Vector minRadius = Vector.getMaximum(diff, diff.multiply(-1.0));
    region.extendRadius(minRadius);
    return true;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:12,代码来源:EllipsoidRegionSelector.java

示例11: build

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double size) throws MaxChangedBlocksException {
    Vector normal = position.subtract(player.getPosition());
    editSession.makeCircle(position, pattern, size, size, size, false, normal);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:6,代码来源:CircleBrush.java

示例12: offset

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
private Vector offset(Vector target, Vector playerPos) {
    if (targetOffset == 0) return target;
    return target.subtract(target.subtract(playerPos).normalize().multiply(targetOffset));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:5,代码来源:BrushTool.java

示例13: fromCenter

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/**
 * Make a cuboid from the center.
 *
 * @param origin  the origin
 * @param apothem the apothem, where 0 is the minimum value to make a 1x1 cuboid
 * @return a cuboid region
 */
public static CuboidRegion fromCenter(Vector origin, int apothem) {
    checkNotNull(origin);
    checkArgument(apothem >= 0, "apothem => 0 required");
    Vector size = new Vector(1, 1, 1).multiply(apothem);
    return new CuboidRegion(origin.subtract(size), origin.add(size));
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:14,代码来源:CuboidRegion.java


注:本文中的com.sk89q.worldedit.Vector.subtract方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。