Java Code Examples for cn.nukkit.math.Vector3#getX()

The following examples show how to use cn.nukkit.math.Vector3#getX() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlockUpdateScheduler.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public Set<BlockUpdateEntry> getPendingBlockUpdates(AxisAlignedBB boundingBox) {
    Set<BlockUpdateEntry> set = null;

    for (Map.Entry<Long, LinkedHashSet<BlockUpdateEntry>> tickEntries : this.queuedUpdates.entrySet()) {
        LinkedHashSet<BlockUpdateEntry> tickSet = tickEntries.getValue();
        for (BlockUpdateEntry update : tickSet) {
            Vector3 pos = update.pos;

            if (pos.getX() >= boundingBox.getMinX() && pos.getX() < boundingBox.getMaxX() && pos.getZ() >= boundingBox.getMinZ() && pos.getZ() < boundingBox.getMaxZ()) {
                if (set == null) {
                    set = new LinkedHashSet<>();
                }

                set.add(update);
            }
        }
    }

    return set;
}
 
Example 2
Source File: Level.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
public List<BlockUpdateEntry> getPendingBlockUpdates(AxisAlignedBB boundingBox) {
    List<BlockUpdateEntry> list = null;

    Iterator<BlockUpdateEntry> iterator;

    iterator = this.updateQueue.iterator();

    while (iterator.hasNext()) {
        BlockUpdateEntry entry = iterator.next();
        Vector3 pos = entry.pos;

        if (pos.getX() >= boundingBox.minX && pos.getX() < boundingBox.maxX && pos.getZ() >= boundingBox.minZ && pos.getZ() < boundingBox.maxZ) {
            if (list == null) {
                list = new ArrayList<>();
            }

            list.add(entry);
        }
    }

    return list;
}
 
Example 3
Source File: BlockUpdateScheduler.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
public Set<BlockUpdateEntry> getPendingBlockUpdates(AxisAlignedBB boundingBox) {
    Set<BlockUpdateEntry> set = null;

    for (Map.Entry<Long, LinkedHashSet<BlockUpdateEntry>> tickEntries : this.queuedUpdates.entrySet()) {
        LinkedHashSet<BlockUpdateEntry> tickSet = tickEntries.getValue();
        for (BlockUpdateEntry update : tickSet) {
            Vector3 pos = update.pos;

            if (pos.getX() >= boundingBox.getMinX() && pos.getX() < boundingBox.getMaxX() && pos.getZ() >= boundingBox.getMinZ() && pos.getZ() < boundingBox.getMaxZ()) {
                if (set == null) {
                    set = new LinkedHashSet<>();
                }

                set.add(update);
            }
        }
    }

    return set;
}
 
Example 4
Source File: PlayerTeleportEvent.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private Location vectorToLocation(Level baseLevel, Vector3 vector) {
    if (vector instanceof Location) return (Location) vector;
    if (vector instanceof Position) return ((Position) vector).getLocation();
    return new Location(vector.getX(), vector.getY(), vector.getZ(), 0, 0, baseLevel);
}
 
Example 5
Source File: Location.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Location add(Vector3 x) {
    return new Location(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.yaw, this.pitch, this.level);
}
 
Example 6
Source File: Position.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Position add(Vector3 x) {
    return new Position(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.level);
}
 
Example 7
Source File: ObjectJungleBigTree.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
    int height = this.getHeight(rand);

    if (!this.ensureGrowable(level, rand, position, height)) {
        return false;
    } else {
        this.createCrown(level, position.up(height), 2);

        for (int j = (int) position.getY() + height - 2 - rand.nextBoundedInt(4); j > position.getY() + height / 2; j -= 2 + rand.nextBoundedInt(4)) {
            float f = rand.nextFloat() * ((float) Math.PI * 2F);
            int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
            int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));

            for (int i1 = 0; i1 < 5; ++i1) {
                k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
                l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
                this.setBlockAndNotifyAdequately(level, new Vector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
            }

            int j2 = 1 + rand.nextBoundedInt(2);
            int j1 = j;

            for (int k1 = j - j2; k1 <= j1; ++k1) {
                int l1 = k1 - j1;
                this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
            }
        }

        for (int i2 = 0; i2 < height; ++i2) {
            Vector3 blockpos = position.up(i2);

            if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
                this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);

                if (i2 > 0) {
                    this.placeVine(level, rand, blockpos.west(), 8);
                    this.placeVine(level, rand, blockpos.north(), 1);
                }
            }

            if (i2 < height - 1) {
                Vector3 blockpos1 = blockpos.east();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos1.east(), 2);
                        this.placeVine(level, rand, blockpos1.north(), 1);
                    }
                }

                Vector3 blockpos2 = blockpos.south().east();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos2.east(), 2);
                        this.placeVine(level, rand, blockpos2.south(), 4);
                    }
                }

                Vector3 blockpos3 = blockpos.south();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos3.west(), 8);
                        this.placeVine(level, rand, blockpos3.south(), 4);
                    }
                }
            }
        }

        return true;
    }
}
 
Example 8
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setDerailedVelocityMod(Vector3 derailed) {
    Objects.requireNonNull(derailed, "Derailed velocity modifiers cannot be null");
    derailedX = derailed.getX();
    derailedY = derailed.getY();
    derailedZ = derailed.getZ();
}
 
Example 9
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setFlyingVelocityMod(Vector3 flying) {
    Objects.requireNonNull(flying, "Flying velocity modifiers cannot be null");
    flyingX = flying.getX();
    flyingY = flying.getY();
    flyingZ = flying.getZ();
}
 
Example 10
Source File: NukkitUtil.java    From FastAsyncWorldedit with GNU General Public License v3.0 4 votes vote down vote up
public static Vector toVector(Vector3 vector) {
    return new Vector(vector.getX(), vector.getY(), vector.getZ());
}
 
Example 11
Source File: PlayerTeleportEvent.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
private Location vectorToLocation(Level baseLevel, Vector3 vector) {
    if (vector instanceof Location) return (Location) vector;
    if (vector instanceof Position) return ((Position) vector).getLocation();
    return new Location(vector.getX(), vector.getY(), vector.getZ(), 0, 0, baseLevel);
}
 
Example 12
Source File: Location.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Location add(Vector3 x) {
    return new Location(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.yaw, this.pitch, this.level);
}
 
Example 13
Source File: EntityMinecartAbstract.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public void setFlyingVelocityMod(Vector3 flying) {
    Objects.requireNonNull(flying, "Flying velocity modifiers cannot be null");
    flyingX = flying.getX();
    flyingY = flying.getY();
    flyingZ = flying.getZ();
}
 
Example 14
Source File: ObjectJungleBigTree.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
    int height = this.getHeight(rand);

    if (!this.ensureGrowable(level, rand, position, height)) {
        return false;
    } else {
        this.createCrown(level, position.up(height), 2);

        for (int j = (int) position.getY() + height - 2 - rand.nextBoundedInt(4); j > position.getY() + height / 2; j -= 2 + rand.nextBoundedInt(4)) {
            float f = rand.nextFloat() * ((float) Math.PI * 2F);
            int k = (int) (position.getX() + (0.5F + MathHelper.cos(f) * 4.0F));
            int l = (int) (position.getZ() + (0.5F + MathHelper.sin(f) * 4.0F));

            for (int i1 = 0; i1 < 5; ++i1) {
                k = (int) (position.getX() + (1.5F + MathHelper.cos(f) * (float) i1));
                l = (int) (position.getZ() + (1.5F + MathHelper.sin(f) * (float) i1));
                this.setBlockAndNotifyAdequately(level, new BlockVector3(k, j - 3 + i1 / 2, l), this.woodMetadata);
            }

            int j2 = 1 + rand.nextBoundedInt(2);

            for (int k1 = j - j2; k1 <= j; ++k1) {
                int l1 = k1 - j;
                this.growLeavesLayer(level, new Vector3(k, k1, l), 1 - l1);
            }
        }

        for (int i2 = 0; i2 < height; ++i2) {
            Vector3 blockpos = position.up(i2);

            if (this.canGrowInto(level.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z))) {
                this.setBlockAndNotifyAdequately(level, blockpos, this.woodMetadata);

                if (i2 > 0) {
                    this.placeVine(level, rand, blockpos.west(), 8);
                    this.placeVine(level, rand, blockpos.north(), 1);
                }
            }

            if (i2 < height - 1) {
                Vector3 blockpos1 = blockpos.east();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos1.x, (int) blockpos1.y, (int) blockpos1.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos1, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos1.east(), 2);
                        this.placeVine(level, rand, blockpos1.north(), 1);
                    }
                }

                Vector3 blockpos2 = blockpos.south().east();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos2.x, (int) blockpos2.y, (int) blockpos2.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos2, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos2.east(), 2);
                        this.placeVine(level, rand, blockpos2.south(), 4);
                    }
                }

                Vector3 blockpos3 = blockpos.south();

                if (this.canGrowInto(level.getBlockIdAt((int) blockpos3.x, (int) blockpos3.y, (int) blockpos3.z))) {
                    this.setBlockAndNotifyAdequately(level, blockpos3, this.woodMetadata);

                    if (i2 > 0) {
                        this.placeVine(level, rand, blockpos3.west(), 8);
                        this.placeVine(level, rand, blockpos3.south(), 4);
                    }
                }
            }
        }

        return true;
    }
}
 
Example 15
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setDerailedVelocityMod(Vector3 derailed) {
    Objects.requireNonNull(derailed, "Derailed velocity modifiers cannot be null");
    derailedX = derailed.getX();
    derailedY = derailed.getY();
    derailedZ = derailed.getZ();
}
 
Example 16
Source File: EntityMinecartAbstract.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
public void setFlyingVelocityMod(Vector3 flying) {
    Objects.requireNonNull(flying, "Flying velocity modifiers cannot be null");
    flyingX = flying.getX();
    flyingY = flying.getY();
    flyingZ = flying.getZ();
}
 
Example 17
Source File: PlayerTeleportEvent.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
private Location vectorToLocation(Level baseLevel, Vector3 vector) {
    if (vector instanceof Location) return (Location) vector;
    if (vector instanceof Position) return ((Position) vector).getLocation();
    return new Location(vector.getX(), vector.getY(), vector.getZ(), 0, 0, baseLevel);
}
 
Example 18
Source File: Location.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Location add(Vector3 x) {
    return new Location(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.yaw, this.pitch, this.level);
}
 
Example 19
Source File: Position.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
@Override
public Position add(Vector3 x) {
    return new Position(this.x + x.getX(), this.y + x.getY(), this.z + x.getZ(), this.level);
}
 
Example 20
Source File: EntityMinecartAbstract.java    From Jupiter with GNU General Public License v3.0 4 votes vote down vote up
public void setDerailedVelocityMod(Vector3 derailed) {
    Objects.requireNonNull(derailed, "Derailed velocity modifiers cannot be null");
    derailedX = derailed.getX();
    derailedY = derailed.getY();
    derailedZ = derailed.getZ();
}