本文整理匯總了Java中com.sk89q.worldedit.Vector.getBlockX方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.getBlockX方法的具體用法?Java Vector.getBlockX怎麽用?Java Vector.getBlockX使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sk89q.worldedit.Vector
的用法示例。
在下文中一共展示了Vector.getBlockX方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: ascendUpwards
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean ascendUpwards(int distance, boolean alwaysGlass) {
final Vector pos = getBlockIn();
final int x = pos.getBlockX();
final int initialY = Math.max(0, pos.getBlockY());
int y = Math.max(0, pos.getBlockY() + 1);
final int z = pos.getBlockZ();
final int maxY = Math.min(getWorld().getMaxY() + 1, initialY + distance);
final World world = getPosition().getWorld();
while (y <= world.getMaxY() + 2) {
if (!BlockType.canPassThrough(world.getBlock(new Vector(x, y, z)))) {
break; // Hit something
} else if (y > maxY + 1) {
break;
} else if (y == maxY + 1) {
floatAt(x, y - 1, z, alwaysGlass);
return true;
}
++y;
}
return false;
}
示例2: adjacentAir
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
public boolean adjacentAir(Vector v) {
int x = v.getBlockX();
int y = v.getBlockY();
int z = v.getBlockZ();
if (!mask.test(x + 1, y, z)) {
return true;
}
if (!mask.test(x - 1, y, z)) {
return true;
}
if (!mask.test(x, y, z + 1)) {
return true;
}
if (!mask.test(x, y, z - 1)) {
return true;
}
if (y < 255 && !mask.test(x, y + 1, z)) {
return true;
}
if (y > 0 && !mask.test(x, y - 1, z)) {
return true;
}
return false;
}
示例3: selectSecondary
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean selectSecondary(Vector position, SelectorLimits limits) {
if (region.size() > 0) {
final List<BlockVector2D> points = region.getPoints();
final BlockVector2D lastPoint = points.get(region.size() - 1);
if (lastPoint.getBlockX() == position.getBlockX() && lastPoint.getBlockZ() == position.getBlockZ()) {
return false;
}
Optional<Integer> vertexLimit = limits.getPolygonVertexLimit();
if (vertexLimit.isPresent() && points.size() > vertexLimit.get()) {
return false;
}
}
region.addPoint(position);
region.expandY(position.getBlockY());
return true;
}
示例4: ArbitraryShape
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
public ArbitraryShape(Region extent) {
this.extent = extent;
Vector min = extent.getMinimumPoint();
Vector max = extent.getMaximumPoint();
cacheOffsetX = min.getBlockX() - 1;
cacheOffsetY = min.getBlockY() - 1;
cacheOffsetZ = min.getBlockZ() - 1;
cacheSizeX = (int) (max.getX() - cacheOffsetX + 2);
cacheSizeY = (int) (max.getY() - cacheOffsetY + 2);
cacheSizeZ = (int) (max.getZ() - cacheOffsetZ + 2);
cache = new short[cacheSizeX * cacheSizeY * cacheSizeZ];
}
示例5: contains
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean contains(Vector position) {
int cx = position.getBlockX() - center.getBlockX();
int cx2 = cx * cx;
if (cx2 > radiusSqr.getBlockX()) {
return false;
}
int cz = position.getBlockZ() - center.getBlockZ();
int cz2 = cz * cz;
if (cz2 > radiusSqr.getBlockZ()) {
return false;
}
int cy = position.getBlockY() - center.getBlockY();
int cy2 = cy * cy;
if (radiusSqr.getBlockY() < 255 && cy2 > radiusSqr.getBlockY()) {
return false;
}
if (sphere) {
return cx2 + cy2 + cz2 <= radiusLengthSqr;
}
double cxd = (double) cx / radius.getBlockX();
double cyd = (double) cy / radius.getBlockY();
double czd = (double) cz / radius.getBlockZ();
return cxd * cxd + cyd * cyd + czd * czd <= 1;
}
示例6: 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);
}
}
示例7: getRelPos
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
private Vector getRelPos(PacketEvent event, HeightMapMCAGenerator generator) {
PacketContainer packet = event.getPacket();
StructureModifier<BlockPosition> position = packet.getBlockPositionModifier();
BlockPosition loc = position.readSafely(0);
if (loc == null) return null;
Vector origin = generator.getOrigin();
Vector pt = new Vector(loc.getX() - origin.getBlockX(), loc.getY() - origin.getBlockY(), loc.getZ() - origin.getBlockZ());
return pt;
}
示例8: getBlock
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public BaseBlock getBlock(Vector position) {
if (region.contains(position)) {
int x = position.getBlockX() - mx;
int y = position.getBlockY() - my;
int z = position.getBlockZ() - mz;
return IMP.getBlock(x, y, z);
}
return EditSession.nullBlock;
}
示例9: fixLighting
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
/**
* Fix the lighting in a selection<br>
* - First removes all lighting, then relights
* - Relights in parallel (if enabled) for best performance<br>
* - Also resends chunks<br>
*
* @param world
* @param selection (assumes cuboid)
* @return
*/
public static int fixLighting(World world, Region selection, @Nullable FaweQueue queue, final FaweQueue.RelightMode mode) {
final Vector bot = selection.getMinimumPoint();
final Vector top = selection.getMaximumPoint();
final int minX = bot.getBlockX() >> 4;
final int minZ = bot.getBlockZ() >> 4;
final int maxX = top.getBlockX() >> 4;
final int maxZ = top.getBlockZ() >> 4;
int count = 0;
if (queue == null) {
queue = SetQueue.IMP.getNewQueue(world, true, false);
}
// Remove existing lighting first
if (queue instanceof NMSMappedFaweQueue) {
final NMSMappedFaweQueue nmsQueue = (NMSMappedFaweQueue) queue;
NMSRelighter relighter = new NMSRelighter(nmsQueue);
for (int x = minX; x <= maxX; x++) {
for (int z = minZ; z <= maxZ; z++) {
relighter.addChunk(x, z, null, 65535);
count++;
}
}
if (mode != FaweQueue.RelightMode.NONE) {
boolean sky = nmsQueue.hasSky();
if (sky) {
relighter.fixSkyLighting();
}
relighter.fixBlockLighting();
} else {
relighter.removeLighting();
}
relighter.sendChunks();
}
return count;
}
示例10: apply
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean apply(Extent extent, Vector set, Vector get) throws WorldEditException {
if (set.getBlockX() == get.getBlockX() && set.getBlockZ() == get.getBlockZ() && set.getBlockY() == get.getBlockY()) {
return false;
}
return extent.setBlock(set, extent.getBlock(get));
}
示例11: apply
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public BaseBlock apply(Vector position) {
int index = (position.getBlockX() + position.getBlockY() + position.getBlockZ()) % patternsArray.length;
if (index < 0) {
index += patternsArray.length;
}
return patternsArray[index].apply(position);
}
示例12: getSlope
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
public int getSlope(BaseBlock block, Vector vector) {
int x = vector.getBlockX();
int y = vector.getBlockY();
int z = vector.getBlockZ();
if (FaweCache.canPassThrough(block.getId(), block.getData())) {
return -1;
}
int slope;
boolean aboveMin;
slope = Math.abs(extent.getNearestSurfaceTerrainBlock(x + 1, z, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - 1, z, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x, z - 1, y, 0, maxY)) * 7;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x + 1, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x - 1, z - 1, y, 0, maxY)) * 5;
slope += Math.abs(extent.getNearestSurfaceTerrainBlock(x - 1, z + 1, y, 0, maxY) - extent.getNearestSurfaceTerrainBlock(x + 1, z - 1, y, 0, maxY)) * 5;
return slope;
}
示例13: getIntDirections
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
private IntegerTrio[] getIntDirections() {
IntegerTrio[] array = new IntegerTrio[directions.size()];
for (int i = 0; i < array.length; i++) {
Vector dir = directions.get(i);
array[i] = new IntegerTrio(dir.getBlockX(), dir.getBlockY(), dir.getBlockZ());
}
return array;
}
示例14: build
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public void build(EditSession editSession, Vector position, Pattern pattern, double sizeDouble) throws MaxChangedBlocksException {
Mask mask = editSession.getMask();
if (mask == Masks.alwaysTrue() || mask == Masks.alwaysTrue2D()) {
mask = null;
}
int size = (int) sizeDouble;
int endY = position.getBlockY() + size;
int startPerformY = Math.max(0, position.getBlockY() - size);
int startCheckY = fullHeight ? 0 : startPerformY;
Vector mutablePos = new Vector(0, 0, 0);
for (int x = position.getBlockX() + size; x > position.getBlockX() - size; --x) {
for (int z = position.getBlockZ() + size; z > position.getBlockZ() - size; --z) {
int freeSpot = startCheckY;
for (int y = startCheckY; y <= endY; y++) {
BaseBlock block = editSession.getLazyBlock(x, y, z);
if (block.getId() != 0) {
if (y != freeSpot) {
editSession.setBlock(x, y, z, EditSession.nullBlock);
editSession.setBlock(x, freeSpot, z, block);
}
freeSpot = y + 1;
}
}
}
}
}
示例15: ClipboardPattern
import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
/**
* Create a new clipboard pattern.
*
* @param clipboard the clipboard
*/
public ClipboardPattern(Clipboard clipboard) {
checkNotNull(clipboard);
this.clipboard = clipboard;
Vector size = clipboard.getMaximumPoint().subtract(clipboard.getMinimumPoint()).add(1, 1, 1);
this.sx = size.getBlockX();
this.sy = size.getBlockY();
this.sz = size.getBlockZ();
this.min = clipboard.getMinimumPoint();
}