當前位置: 首頁>>代碼示例>>Java>>正文


Java Vector.mutY方法代碼示例

本文整理匯總了Java中com.sk89q.worldedit.Vector.mutY方法的典型用法代碼示例。如果您正苦於以下問題:Java Vector.mutY方法的具體用法?Java Vector.mutY怎麽用?Java Vector.mutY使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.sk89q.worldedit.Vector的用法示例。


在下文中一共展示了Vector.mutY方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setBlock

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean setBlock(Vector location, BaseBlock block) throws WorldEditException {
    boolean result = false;
    Vector pos = getPos(location);
    double sx = pos.getX();
    double sy = pos.getY();
    double sz = pos.getZ();
    double ex = sx + dx;
    double ey = Math.min(maxy, sy + dy);
    double ez = sz + dz;
    for (pos.mutY(sy); pos.getY() < ey; pos.mutY(pos.getY() + 1)) {
        for (pos.mutZ(sz); pos.getZ() < ez; pos.mutZ(pos.getZ() + 1)) {
            for (pos.mutX(sx); pos.getX() < ex; pos.mutX(pos.getX() + 1)) {
                result |= super.setBlock(pos, block);
            }
        }
    }
    return result;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:20,代碼來源:ScaleTransform.java

示例2: retainAll

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean retainAll(Collection<?> c) {
    boolean result = false;
    int size = size();
    int index = -1;
    Vector mVec = MutableBlockVector.get(0, 0, 0);
    for (int i = 0; i < size; i++) {
        index = set.nextSetBit(index + 1);
        int b1 = (index & 0xFF);
        int b2 = ((byte) (index >> 8)) & 0x7F;
        int b3 = ((byte) (index >> 15)) & 0xFF;
        int b4 = ((byte) (index >> 23)) & 0xFF;
        mVec.mutX(offsetX + (((b3 + ((MathMan.unpair8x(b2)) << 8)) << 21) >> 21));
        mVec.mutY(b1);
        mVec.mutZ(offsetZ + (((b4 + ((MathMan.unpair8y(b2)) << 8)) << 21) >> 21));
        if (!c.contains(mVec)) {
            result = true;
            set.clear(index);
        }
    }
    return result;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:23,代碼來源:LocalBlockVectorSet.java

示例3: setSelection

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
/**
 * Set the player's WorldEdit selection to the following CuboidRegion
 *
 * @param region
 */
public void setSelection(final RegionWrapper region) {
    final Player player = this.getPlayer();
    Vector top = region.getTopVector();
    top.mutY(getWorld().getMaxY());
    final RegionSelector selector = new CuboidRegionSelector(player.getWorld(), region.getBottomVector(), top);
    this.getSession().setRegionSelector(player.getWorld(), selector);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:13,代碼來源:FawePlayer.java

示例4: getCentroid

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
private Vector getCentroid(Collection<Vector> points) {
    Vector sum = new Vector();
    for (Vector p : points) {
        sum.mutX(sum.getX() + p.getX());
        sum.mutY(sum.getY() + p.getY());
        sum.mutZ(sum.getZ() + p.getZ());
    }
    return sum.multiply(1.0 / points.size());
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:10,代碼來源:SplineBrush.java

示例5: fromClipboard

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
public static ScalableHeightMap fromClipboard(Clipboard clipboard) {
    Vector dim = clipboard.getDimensions();
    byte[][] heightArray = new byte[dim.getBlockX()][dim.getBlockZ()];
    int minX = clipboard.getMinimumPoint().getBlockX();
    int minZ = clipboard.getMinimumPoint().getBlockZ();
    int minY = clipboard.getMinimumPoint().getBlockY();
    int maxY = clipboard.getMaximumPoint().getBlockY();
    int clipHeight = maxY - minY + 1;
    HashSet<IntegerPair> visited = new HashSet<>();
    for (Vector pos : clipboard.getRegion()) {
        IntegerPair pair = new IntegerPair(pos.getBlockX(), pos.getBlockZ());
        if (visited.contains(pair)) {
            continue;
        }
        visited.add(pair);
        int xx = pos.getBlockX();
        int zz = pos.getBlockZ();
        int highestY = minY;
        for (int y = minY; y <= maxY; y++) {
            pos.mutY(y);
            BaseBlock block = clipboard.getBlock(pos);
            if (block.getId() != 0) {
                highestY = y + 1;
            }
        }
        int pointHeight = Math.min(255, (256 * (highestY - minY)) / clipHeight);
        int x = xx - minX;
        int z = zz - minZ;
        heightArray[x][z] = (byte) pointHeight;
    }
    return new ArrayHeightMap(heightArray);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:33,代碼來源:ScalableHeightMap.java

示例6: transformNbtData

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
/**
 * Transform NBT data in the given block state and return a new instance
 * if the NBT data needs to be transformed.
 *
 * @param state the existing state
 * @return a new state or the existing one
 */
private BaseBlock transformNbtData(BaseBlock state) {
    CompoundTag tag = state.getNbtData();
    if (tag != null) {
        // Handle blocks which store their rotation in NBT
        if (tag.containsKey("Rot")) {
            int rot = tag.asInt("Rot");

            Direction direction = MCDirections.fromRotation(rot);

            if (direction != null) {
                Vector applyAbsolute = transform.apply(direction.toVector());
                Vector applyOrigin = transform.apply(Vector.ZERO);
                applyAbsolute.mutX(applyAbsolute.getX() - applyOrigin.getX());
                applyAbsolute.mutY(applyAbsolute.getY() - applyOrigin.getY());
                applyAbsolute.mutZ(applyAbsolute.getZ() - applyOrigin.getZ());

                Direction newDirection = Direction.findClosest(applyAbsolute, Flag.CARDINAL | Flag.ORDINAL | Flag.SECONDARY_ORDINAL);

                if (newDirection != null) {
                    Map<String, Tag> values = ReflectionUtils.getMap(tag.getValue());
                    values.put("Rot", new ByteTag((byte) MCDirections.toRotation(newDirection)));
                }
            }
        }
    }
    return state;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:35,代碼來源:ExtentBlockCopy.java

示例7: allowed

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
private boolean allowed(Vector v) {
    BaseBlock block = pattern.apply(v);
    if (FaweCache.canPassThrough(block.getId(), block.getData())) {
        return false;
    }
    int x = v.getBlockX();
    int y = v.getBlockY();
    int z = v.getBlockZ();
    v.mutY(y + 1);
    if (canPassthrough(v)) {
        v.mutY(y);
        return true;
    }
    v.mutY(y - 1);
    if (canPassthrough(v)) {
        v.mutY(y);
        return true;
    }
    v.mutY(y);
    v.mutX(x + 1);
    if (canPassthrough(v)) {
        v.mutX(x);
        return true;
    }
    v.mutX(x - 1);
    if (canPassthrough(v)) {
        v.mutX(x);
        return true;
    }
    v.mutX(x);
    v.mutZ(z + 1);
    if (canPassthrough(v)) {
        v.mutZ(z);
        return true;
    }
    v.mutZ(z - 1);
    if (canPassthrough(v)) {
        v.mutZ(z);
        return true;
    }
    v.mutZ(z);
    return false;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:44,代碼來源:SurfaceRandomOffsetPattern.java

示例8: test

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean test(Vector v) {
    int count = 0;
    double x = v.getX();
    double y = v.getY();
    double z = v.getZ();
    v.mutX(x + 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutX(x);
        return true;
    }
    v.mutX(x - 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutX(x);
        return true;
    }
    v.mutX(x);
    v.mutY(y + 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutY(y);
        return true;
    }
    v.mutY(y - 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutY(y);
        return true;
    }
    v.mutY(y);
    v.mutZ(z + 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutZ(z);
        return true;
    }
    v.mutZ(z - 1);
    if (mask.test(v) && ++count == min && max >= 8) {
        v.mutZ(z);
        return true;
    }
    v.mutZ(z);
    return count >= min && count <= max;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:42,代碼來源:AdjacentMask.java

示例9: resume

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public Operation resume(RunContext run) throws WorldEditException {
    NodePair current;
    Node from;
    Node adjacent;
    MutableBlockVector mutable = new MutableBlockVector();
    Vector mutable2 = new Vector();
    int countAdd, countAttempt;
    IntegerTrio[] dirs = getIntDirections();

    for (int layer = 0; !queue.isEmpty(); layer++) {
        current = queue.poll();
        from = current.to;
        hashQueue.remove(from);
        if (visited.containsKey(from)) {
            continue;
        }
        mutable.mutX(from.getX());
        mutable.mutY(from.getY());
        mutable.mutZ(from.getZ());
        function.apply(mutable);
        countAdd = 0;
        countAttempt = 0;
        for (IntegerTrio direction : dirs) {
            mutable2.mutX(from.getX() + direction.x);
            mutable2.mutY(from.getY() + direction.y);
            mutable2.mutZ(from.getZ() + direction.z);
            if (isVisitable(mutable, mutable2)) {
                adjacent = new Node(mutable2.getBlockX(), mutable2.getBlockY(), mutable2.getBlockZ());
                if ((current.from == null || !adjacent.equals(current.from))) {
                    AtomicInteger adjacentCount = visited.get(adjacent);
                    if (adjacentCount == null) {
                        if (countAdd++ < maxBranch) {
                            if (!hashQueue.contains(adjacent)) {
                                if (current.depth == maxDepth) {
                                    countAttempt++;
                                } else {
                                    hashQueue.add(adjacent);
                                    queue.addFirst(new NodePair(from, adjacent, current.depth + 1));
                                }
                            } else {
                                countAttempt++;
                            }
                        } else {
                            countAttempt++;
                        }
                    } else if (adjacentCount.decrementAndGet() == 0) {
                        visited.remove(adjacent);
                    } else if (hashQueue.contains(adjacent)) {
                        countAttempt++;
                    }
                }
            }
        }
        if (countAttempt > 0) {
            visited.put(from, new AtomicInteger(countAttempt));
        }
        affected++;
    }
    return null;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:62,代碼來源:DFSVisitor.java

示例10: build

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public void build(EditSession editSession, Vector pos, Pattern pattern, double radius) throws MaxChangedBlocksException {
    int maxY = editSession.getMaxY();
    boolean vis = editSession.getExtent() instanceof VisualExtent;
    if (path.isEmpty() || !pos.equals(path.get(path.size() - 1))) {
        int max = editSession.getNearestSurfaceTerrainBlock(pos.getBlockX(), pos.getBlockZ(), pos.getBlockY(), 0, editSession.getMaxY());
        if (max == -1) return;
        pos.mutY(max);
        path.add(pos);
        editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_PRIMARY_2.s());
        if (!vis) return;
    }
    LocalBlockVectorSet vset = new LocalBlockVectorSet();
    final List<Node> nodes = new ArrayList<>(path.size());
    final KochanekBartelsInterpolation interpol = new KochanekBartelsInterpolation();

    for (final Vector nodevector : path) {
        final Node n = new Node(nodevector);
        n.setTension(tension);
        n.setBias(bias);
        n.setContinuity(continuity);
        nodes.add(n);
    }
    interpol.setNodes(nodes);
    final double splinelength = interpol.arcLength(0, 1);
    for (double loop = 0; loop <= 1; loop += 1D / splinelength / quality) {
        final Vector tipv = interpol.getPosition(loop);
        final int tipx = MathMan.roundInt(tipv.getX());
        final int tipz = (int) tipv.getZ();
        int tipy = MathMan.roundInt(tipv.getY());
        tipy = editSession.getNearestSurfaceTerrainBlock(tipx, tipz, tipy, 0, maxY);
        if (tipy == -1) continue;
        if (radius == 0) {
            editSession.setBlock(tipx, tipy, tipz, pattern.next(tipx, tipy, tipz));
        } else {
            vset.add(tipx, tipy, tipz);
        }
    }
    if (radius != 0) {
        double radius2 = (radius * radius);
        LocalBlockVectorSet newSet = new LocalBlockVectorSet();
        final int ceilrad = (int) Math.ceil(radius);
        for (final Vector v : vset) {
            final int tipx = v.getBlockX(), tipy = v.getBlockY(), tipz = v.getBlockZ();
            for (int loopx = tipx - ceilrad; loopx <= (tipx + ceilrad); loopx++) {
                for (int loopz = tipz - ceilrad; loopz <= (tipz + ceilrad); loopz++) {
                    if (MathMan.hypot2(loopx - tipx, 0, loopz - tipz) <= radius2) {
                        int y = editSession.getNearestSurfaceTerrainBlock(loopx, loopz, v.getBlockY(), 0, maxY);
                        if (y == -1) continue;
                        newSet.add(loopx, y, loopz);
                    }
                }
            }
        }
        editSession.setBlocks(newSet, pattern);
        if (!vis) path.clear();
    }
    editSession.getPlayer().sendMessage(BBC.getPrefix() + BBC.BRUSH_SPLINE_SECONDARY.s());
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:60,代碼來源:SurfaceSpline.java

示例11: getTransformedRegion

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
/**
 * Get the transformed region.
 *
 * @return the transformed region
 */
public Region getTransformedRegion() {
    Region region = original.getRegion();
    Vector minimum = region.getMinimumPoint();
    Vector maximum = region.getMaximumPoint();

    Transform transformAround =
            new CombinedTransform(
                    new AffineTransform().translate(original.getOrigin().multiply(-1)),
                    transform,
                    new AffineTransform().translate(original.getOrigin()));

    // new Vector(minimum.getX(), minimum.getY(), minimum.getZ())
    // new Vector(maximum.getX(), maximum.getY(), maximum.getZ())
    Vector[] corners = new Vector[]{
            minimum,
            maximum,
            new Vector(maximum.getX(), minimum.getY(), minimum.getZ()),
            new Vector(minimum.getX(), maximum.getY(), minimum.getZ()),
            new Vector(minimum.getX(), minimum.getY(), maximum.getZ()),
            new Vector(minimum.getX(), maximum.getY(), maximum.getZ()),
            new Vector(maximum.getX(), minimum.getY(), maximum.getZ()),
            new Vector(maximum.getX(), maximum.getY(), minimum.getZ())};

    for (int i = 0; i < corners.length; i++) {
        corners[i] = transformAround.apply(new Vector(corners[i]));
    }

    Vector newMinimum = corners[0];
    Vector newMaximum = corners[0];

    for (int i = 1; i < corners.length; i++) {
        newMinimum = Vector.getMinimum(newMinimum, corners[i]);
        newMaximum = Vector.getMaximum(newMaximum, corners[i]);
    }

    // After transformation, the points may not really sit on a block,
    // so we should expand the region for edge cases
    newMinimum.mutX(Math.ceil(Math.floor(newMinimum.getX())));
    newMinimum.mutY(Math.ceil(Math.floor(newMinimum.getY())));
    newMinimum.mutZ(Math.ceil(Math.floor(newMinimum.getZ())));

    return new CuboidRegion(newMinimum, newMaximum);
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:49,代碼來源:FlattenedClipboardTransform.java


注:本文中的com.sk89q.worldedit.Vector.mutY方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。