Package com.sk89q.worldedit

Examples of com.sk89q.worldedit.Vector


     * @param oldDirection the old direction to transform
     * @return a new state or null if none could be found
     */
    @Nullable
    private static StateValue getNewStateValue(State state, Transform transform, Vector oldDirection) {
        Vector newDirection = transform.apply(oldDirection).subtract(transform.apply(Vector.ZERO)).normalize();
        StateValue newValue = null;
        double closest = -2;
        boolean found = false;

        for (StateValue v : state.valueMap().values()) {
View Full Code Here


    public static World adapt(net.minecraft.world.World world) {
        return new ForgeWorld(world);
    }

    public static Vector adapt(Vec3 vector) {
        return new Vector(vector.xCoord, vector.yCoord, vector.zCoord);
    }
View Full Code Here

     * @return the new object
     */
    private Object prepareSerialization(Object value) {
        if (value instanceof Vector) {
            Map<String, Double> out = new LinkedHashMap<String, Double>();
            Vector vec = (Vector) value;
            out.put("x", vec.getX());
            out.put("y", vec.getY());
            out.put("z", vec.getZ());
            return out;
        }

        return value;
    }
View Full Code Here

        if (x == null || y == null || z == null) {
            return null;
        }

        return new Vector(x, y, z);
    }
View Full Code Here

     * @param path path to node (dot notation)
     * @param def default value
     * @return string or default
     */
    public Vector getVector(String path, Vector def) {
        Vector v = getVector(path);
        if (v == null) {
            if (writeDefaults) setProperty(path, def);
            return def;
        }
        return v;
View Full Code Here

            if (x == null || y == null || z == null) {
                continue;
            }

            list.add(new Vector(x, y, z));
        }

        return list;
    }
View Full Code Here

        throw new UnsupportedOperationException("Cannot create a state from this object");
    }

    @Override
    public Location getLocation() {
        Vector position = new Vector(this.player.posX, this.player.posY, this.player.posZ);
        return new Location(
                ForgeWorldEdit.inst.getWorld(this.player.worldObj),
                position,
                this.player.cameraYaw,
                this.player.cameraPitch);
View Full Code Here

    @Override
    public Location getLocation() {
        net.minecraft.entity.Entity entity = entityRef.get();
        if (entity != null) {
            Vector position = new Vector(entity.posX, entity.posY, entity.posZ);
            float yaw = entity.rotationYaw;
            float pitch = entity.rotationPitch;

            return new Location(ForgeAdapter.adapt(entity.worldObj), position, yaw, pitch);
        } else {
View Full Code Here

     */

    public int apply(int[] data) throws MaxChangedBlocksException {
        checkNotNull(data);

        Vector minY = region.getMinimumPoint();
        int originX = minY.getBlockX();
        int originY = minY.getBlockY();
        int originZ = minY.getBlockZ();

        int maxY = region.getMaximumPoint().getBlockY();
        BaseBlock fillerAir = new BaseBlock(BlockID.AIR);

        int blocksChanged = 0;

        // Apply heightmap
        for (int z = 0; z < height; ++z) {
            for (int x = 0; x < width; ++x) {
                int index = z * width + x;
                int curHeight = this.data[index];

                // Clamp newHeight within the selection area
                int newHeight = Math.min(maxY, data[index]);

                // Offset x,z to be 'real' coordinates
                int xr = x + originX;
                int zr = z + originZ;

                // We are keeping the topmost blocks so take that in account for the scale
                double scale = (double) (curHeight - originY) / (double) (newHeight - originY);

                // Depending on growing or shrinking we need to start at the bottom or top
                if (newHeight > curHeight) {
                    // Set the top block of the column to be the same type (this might go wrong with rounding)
                    BaseBlock existing = session.getBlock(new Vector(xr, curHeight, zr));

                    // Skip water/lava
                    if (existing.getType() != BlockID.WATER && existing.getType() != BlockID.STATIONARY_WATER
                            && existing.getType() != BlockID.LAVA && existing.getType() != BlockID.STATIONARY_LAVA) {
                        session.setBlock(new Vector(xr, newHeight, zr), existing);
                        ++blocksChanged;

                        // Grow -- start from 1 below top replacing airblocks
                        for (int y = newHeight - 1 - originY; y >= 0; --y) {
                            int copyFrom = (int) (y * scale);
                            session.setBlock(new Vector(xr, originY + y, zr), session.getBlock(new Vector(xr, originY + copyFrom, zr)));
                            ++blocksChanged;
                        }
                    }
                } else if (curHeight > newHeight) {
                    // Shrink -- start from bottom
                    for (int y = 0; y < newHeight - originY; ++y) {
                        int copyFrom = (int) (y * scale);
                        session.setBlock(new Vector(xr, originY + y, zr), session.getBlock(new Vector(xr, originY + copyFrom, zr)));
                        ++blocksChanged;
                    }

                    // Set the top block of the column to be the same type
                    // (this could otherwise go wrong with rounding)
                    session.setBlock(new Vector(xr, newHeight, zr), session.getBlock(new Vector(xr, curHeight, zr)));
                    ++blocksChanged;

                    // Fill rest with air
                    for (int y = newHeight + 1; y <= curHeight; ++y) {
                        session.setBlock(new Vector(xr, y, zr), fillerAir);
                        ++blocksChanged;
                    }
                }
            }
        }
View Full Code Here

        return scale(vec.getX(), vec.getY(), vec.getZ());
    }

    @Override
    public Vector apply(Vector vector) {
        return new Vector(
                vector.getX() * m00 + vector.getY() * m01 + vector.getZ() * m02 + m03,
                vector.getX() * m10 + vector.getY() * m11 + vector.getZ() * m12 + m13,
                vector.getX() * m20 + vector.getY() * m21 + vector.getZ() * m22 + m23);
    }
View Full Code Here

TOP

Related Classes of com.sk89q.worldedit.Vector

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.