本文整理匯總了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;
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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
}
}
示例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
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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();
}
示例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;
}
}
示例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);
}
示例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));
}