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


Java Vector.mutX方法代碼示例

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


在下文中一共展示了Vector.mutX方法的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: get

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
public Vector get(int index) {
    int count = 0;
    ObjectIterator<Int2ObjectMap.Entry<LocalBlockVectorSet>> iter = localSets.int2ObjectEntrySet().iterator();
    while (iter.hasNext()) {
        Int2ObjectMap.Entry<LocalBlockVectorSet> entry = iter.next();
        LocalBlockVectorSet set = entry.getValue();
        int size = set.size();
        int newSize = count + size;
        if (newSize > index) {
            int localIndex = index - count;
            Vector pos = set.getIndex(localIndex);
            if (pos != null) {
                int pair = entry.getIntKey();
                int cx = MathMan.unpairX(pair);
                int cz = MathMan.unpairY(pair);
                pos.mutX((cx << 11) + pos.getBlockX());
                pos.mutZ((cz << 11) + pos.getBlockZ());
                return pos;
            }
        }
        count += newSize;
    }
    return null;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:25,代碼來源:BlockVectorSet.java

示例4: setBiome

import com.sk89q.worldedit.Vector; //導入方法依賴的package包/類
@Override
public boolean setBiome(Vector2D position, BaseBiome biome) {
    boolean result = false;
    Vector pos = getPos(position.getBlockX(), 0, position.getBlockZ());
    double sx = pos.getX();
    double sz = pos.getZ();
    double ex = pos.getX() + dx;
    double ez = pos.getZ() + dz;
    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.setBiome(pos.toVector2D(), biome);
        }
    }
    return result;
}
 
開發者ID:boy0001,項目名稱:FastAsyncWorldedit,代碼行數:16,代碼來源:ScaleTransform.java

示例5: 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.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,代碼行數:31,代碼來源:WallMask.java

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

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

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

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

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

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