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


Java Vector.add方法代码示例

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


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

示例1: shift

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
@Override
public void shift(Vector change) throws RegionOperationException {
    shiftCollection(vertices, change);
    shiftCollection(vertexBacklog, change);

    for (int i = 0; i < triangles.size(); ++i) {
        final Triangle triangle = triangles.get(i);

        final Vector v0 = change.add(triangle.getVertex(0));
        final Vector v1 = change.add(triangle.getVertex(1));
        final Vector v2 = change.add(triangle.getVertex(2));

        triangles.set(i, new Triangle(v0, v1, v2));
    }

    minimumPoint = change.add(minimumPoint);
    maximumPoint = change.add(maximumPoint);
    centerAccum = change.multiply(vertices.size()).add(centerAccum);
    lastTriangle = null;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:21,代码来源:PolyhedralRegion.java

示例2: 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

示例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: placeBuildPlan2D

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/**Places the given material where the plan is true, starting from the given relative origin within this module.
 * The plan and origin are rotated beforehand, to avoid conversion toGlobal for each block!
 * @param origin	A relative coordinate specifying the minimum Point of the given build plan
 * @param plan		A grid of boolean values. Material is set if true at that position.
 * @param m			The Material to be placed.
 * @param height	How high the plan should be duplicated. (stacked up)
 */
public void placeBuildPlan2D(Vector origin, boolean[][] plan, Material m, int height) {
	plan = Helper.rotateBoolMatrixClockw(plan, turnedBy); //clockwise turning as is defined in mc for sky directions
	// The origin has to be at another corner of the matrix now:
	origin = toGlobal(origin);
	switch (turnedBy) {
	case 0:
		break;
	case 90:
		origin = origin.add(-(plan.length-1), 0, 0);
		break;
	case 180:
		origin = origin.add(-(plan.length-1),0,-(plan[0].length-1));
		break;
	case 270:
		origin = origin.add(0, 0, -(plan[0].length-1));
		break;
	default:
		parent.setStateAndNotify(State.ERROR, "Module: turnedBy is out of range: " + turnedBy + ". Plan is not placed.");
		return;
	}
	
	// now we have a building plan matrix looking east, with the origin in the lower left. Easy:
	int x = origin.getBlockX();
	for (int row=0; row < plan.length; row++, x++) {
		int z = origin.getBlockZ();
		for (int col=0; col< plan[0].length; col++, z++)
			for (int y = origin.getBlockY(); y < (origin.getBlockY()+height); y++)
				if (plan[row][col]) parent.world.getBlockAt(x,y,z).setType(m);	
	}
		
}
 
开发者ID:TheRoot89,项目名称:DungeonGen,代码行数:39,代码来源:Module.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: sendBlockChange

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
private boolean sendBlockChange(Player plr, HeightMapMCAGenerator gen, Vector pt, Interaction action) {
    PlatformManager platform = WorldEdit.getInstance().getPlatformManager();
    com.sk89q.worldedit.entity.Player actor = FawePlayer.wrap(plr).getPlayer();
    com.sk89q.worldedit.util.Location location = new com.sk89q.worldedit.util.Location(actor.getWorld(), pt);
    BlockInteractEvent toCall = new BlockInteractEvent(actor, location, action);
    platform.handleBlockInteract(toCall);
    if (toCall.isCancelled() || action == Interaction.OPEN) {
        Vector realPos = pt.add(gen.getOrigin());
        BaseBlock block = gen.getBlock(pt);
        sendBlockChange(plr, realPos, block);
        return true;
    }
    return false;
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:15,代码来源:CFIPacketListener.java

示例8: getRelative

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
private Vector getRelative(PacketEvent container, Vector pt) {
    PacketContainer packet = container.getPacket();
    StructureModifier<EnumWrappers.Direction> dirs = packet.getDirections();
    EnumWrappers.Direction dir = dirs.readSafely(0);
    if (dir == null) return pt;
    switch (dir.ordinal()) {
        case 0: return pt.add(0, -1, 0);
        case 1: return pt.add(0, 1, 0);
        case 2: return pt.add(0, 0, -1);
        case 3: return pt.add(0, 0, 1);
        case 4: return pt.add(-1, 0, 0);
        case 5: return pt.add(1, 0, 0);
        default: return pt;
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:16,代码来源:CFIPacketListener.java

示例9: 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

示例10: calculateChanges

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
private Vector calculateChanges(Vector... changes) {
    Vector total = new Vector();
    for (Vector change : changes) {
        total = total.add(change.positive());
    }

    return total.divide(2).floor();
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:9,代码来源:EllipsoidRegion.java

示例11: setRadius

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
/**
 * Set the radii.
 *
 * @param radius the radius
 */
public void setRadius(Vector radius) {
    this.radius = new MutableBlockVector(radius.add(0.5, 0.5, 0.5));
    radiusSqr = new MutableBlockVector(radius.multiply(radius));
    radiusLengthSqr = radiusSqr.getBlockX();
    if (radius.getBlockY() == radius.getBlockX() && radius.getBlockX() == radius.getBlockZ()) {
        this.sphere = true;
    } else {
        this.sphere = false;
    }
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:16,代码来源:EllipsoidRegion.java

示例12: WorldEditExpressionEnvironment

import com.sk89q.worldedit.Vector; //导入方法依赖的package包/类
public WorldEditExpressionEnvironment(Extent extent, Vector unit, Vector zero) {
    this.extent = extent;
    this.unit = unit;
    this.zero2 = zero.add(0.5, 0.5, 0.5);
}
 
开发者ID:boy0001,项目名称:FastAsyncWorldedit,代码行数:6,代码来源:WorldEditExpressionEnvironment.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.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。