Search in sources :

Example 56 with Vector3

use of cn.nukkit.math.Vector3 in project Nukkit by Nukkit.

the class HugeTreesGenerator method growLeavesLayer.

/**
 * grow leaves in a circle
 */
protected void growLeavesLayer(ChunkManager worldIn, Vector3 layerCenter, int width) {
    int i = width * width;
    for (int j = -width; j <= width; ++j) {
        for (int k = -width; k <= width; ++k) {
            if (j * j + k * k <= i) {
                Vector3 blockpos = layerCenter.add(j, 0, k);
                int id = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);
                if (id == Block.AIR || id == Block.LEAVES) {
                    this.setBlockAndNotifyAdequately(worldIn, blockpos, this.leavesMetadata);
                }
            }
        }
    }
}
Also used : Vector3(cn.nukkit.math.Vector3)

Example 57 with Vector3

use of cn.nukkit.math.Vector3 in project Nukkit by Nukkit.

the class ObjectDarkOakTree method generate.

@Override
public boolean generate(ChunkManager level, NukkitRandom rand, Vector3 position) {
    int i = rand.nextBoundedInt(3) + rand.nextBoundedInt(2) + 6;
    int j = position.getFloorX();
    int k = position.getFloorY();
    int l = position.getFloorZ();
    if (k >= 1 && k + i + 1 < 256) {
        Vector3 blockpos = position.down();
        int block = level.getBlockIdAt(blockpos.getFloorX(), blockpos.getFloorY(), blockpos.getFloorZ());
        if (block != Block.GRASS && block != Block.DIRT) {
            return false;
        } else if (!this.placeTreeOfHeight(level, position, i)) {
            return false;
        } else {
            this.setDirtAt(level, blockpos);
            this.setDirtAt(level, blockpos.east());
            this.setDirtAt(level, blockpos.south());
            this.setDirtAt(level, blockpos.south().east());
            BlockFace enumfacing = BlockFace.Plane.HORIZONTAL.random(rand);
            int i1 = i - rand.nextBoundedInt(4);
            int j1 = 2 - rand.nextBoundedInt(3);
            int k1 = j;
            int l1 = l;
            int i2 = k + i - 1;
            for (int j2 = 0; j2 < i; ++j2) {
                if (j2 >= i1 && j1 > 0) {
                    k1 += enumfacing.getXOffset();
                    l1 += enumfacing.getZOffset();
                    --j1;
                }
                int k2 = k + j2;
                Vector3 blockpos1 = new Vector3(k1, k2, l1);
                int material = level.getBlockIdAt(blockpos1.getFloorX(), blockpos1.getFloorY(), blockpos1.getFloorZ());
                if (material == Block.AIR || material == Block.LEAVES) {
                    this.placeLogAt(level, blockpos1);
                    this.placeLogAt(level, blockpos1.east());
                    this.placeLogAt(level, blockpos1.south());
                    this.placeLogAt(level, blockpos1.east().south());
                }
            }
            for (int i3 = -2; i3 <= 0; ++i3) {
                for (int l3 = -2; l3 <= 0; ++l3) {
                    int k4 = -1;
                    this.placeLeafAt(level, k1 + i3, i2 + k4, l1 + l3);
                    this.placeLeafAt(level, 1 + k1 - i3, i2 + k4, l1 + l3);
                    this.placeLeafAt(level, k1 + i3, i2 + k4, 1 + l1 - l3);
                    this.placeLeafAt(level, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
                    if ((i3 > -2 || l3 > -1) && (i3 != -1 || l3 != -2)) {
                        k4 = 1;
                        this.placeLeafAt(level, k1 + i3, i2 + k4, l1 + l3);
                        this.placeLeafAt(level, 1 + k1 - i3, i2 + k4, l1 + l3);
                        this.placeLeafAt(level, k1 + i3, i2 + k4, 1 + l1 - l3);
                        this.placeLeafAt(level, 1 + k1 - i3, i2 + k4, 1 + l1 - l3);
                    }
                }
            }
            if (rand.nextBoolean()) {
                this.placeLeafAt(level, k1, i2 + 2, l1);
                this.placeLeafAt(level, k1 + 1, i2 + 2, l1);
                this.placeLeafAt(level, k1 + 1, i2 + 2, l1 + 1);
                this.placeLeafAt(level, k1, i2 + 2, l1 + 1);
            }
            for (int j3 = -3; j3 <= 4; ++j3) {
                for (int i4 = -3; i4 <= 4; ++i4) {
                    if ((j3 != -3 || i4 != -3) && (j3 != -3 || i4 != 4) && (j3 != 4 || i4 != -3) && (j3 != 4 || i4 != 4) && (Math.abs(j3) < 3 || Math.abs(i4) < 3)) {
                        this.placeLeafAt(level, k1 + j3, i2, l1 + i4);
                    }
                }
            }
            for (int k3 = -1; k3 <= 2; ++k3) {
                for (int j4 = -1; j4 <= 2; ++j4) {
                    if ((k3 < 0 || k3 > 1 || j4 < 0 || j4 > 1) && rand.nextBoundedInt(3) <= 0) {
                        int l4 = rand.nextBoundedInt(3) + 2;
                        for (int i5 = 0; i5 < l4; ++i5) {
                            this.placeLogAt(level, new Vector3(j + k3, i2 - i5 - 1, l + j4));
                        }
                        for (int j5 = -1; j5 <= 1; ++j5) {
                            for (int l2 = -1; l2 <= 1; ++l2) {
                                this.placeLeafAt(level, k1 + k3 + j5, i2, l1 + j4 + l2);
                            }
                        }
                        for (int k5 = -2; k5 <= 2; ++k5) {
                            for (int l5 = -2; l5 <= 2; ++l5) {
                                if (Math.abs(k5) != 2 || Math.abs(l5) != 2) {
                                    this.placeLeafAt(level, k1 + k3 + k5, i2 - 1, l1 + j4 + l5);
                                }
                            }
                        }
                    }
                }
            }
            return true;
        }
    } else {
        return false;
    }
}
Also used : BlockFace(cn.nukkit.math.BlockFace) Vector3(cn.nukkit.math.Vector3)

Example 58 with Vector3

use of cn.nukkit.math.Vector3 in project Nukkit by Nukkit.

the class SavannaTreePopulator method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectSavannaTree().generate(level, random, v.setComponents(x, y, z));
    }
}
Also used : ObjectSavannaTree(cn.nukkit.level.generator.object.tree.ObjectSavannaTree) Vector3(cn.nukkit.math.Vector3)

Example 59 with Vector3

use of cn.nukkit.math.Vector3 in project Nukkit by Nukkit.

the class SwampTreePopulator method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectSwampTree().generate(level, random, v.setComponents(x, y, z));
    }
}
Also used : ObjectSwampTree(cn.nukkit.level.generator.object.tree.ObjectSwampTree) Vector3(cn.nukkit.math.Vector3)

Example 60 with Vector3

use of cn.nukkit.math.Vector3 in project Nukkit by Nukkit.

the class JungleBigTreePopulator method populate.

@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    Vector3 v = new Vector3();
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        new ObjectJungleBigTree(10, 20, new BlockWood(BlockWood.JUNGLE), new BlockLeaves(BlockLeaves.JUNGLE)).generate(this.level, random, v.setComponents(x, y, z));
    }
}
Also used : BlockLeaves(cn.nukkit.block.BlockLeaves) ObjectJungleBigTree(cn.nukkit.level.generator.object.tree.ObjectJungleBigTree) Vector3(cn.nukkit.math.Vector3) BlockWood(cn.nukkit.block.BlockWood)

Aggregations

Vector3 (cn.nukkit.math.Vector3)62 BlockFace (cn.nukkit.math.BlockFace)16 Block (cn.nukkit.block.Block)5 Player (cn.nukkit.Player)3 Entity (cn.nukkit.entity.Entity)3 BlockIgniteEvent (cn.nukkit.event.block.BlockIgniteEvent)3 Random (java.util.Random)3 ThreadLocalRandom (java.util.concurrent.ThreadLocalRandom)3 EntityLiving (cn.nukkit.entity.EntityLiving)2 BlockRedstoneEvent (cn.nukkit.event.block.BlockRedstoneEvent)2 BlockSpreadEvent (cn.nukkit.event.block.BlockSpreadEvent)2 VehicleMoveEvent (cn.nukkit.event.vehicle.VehicleMoveEvent)2 VehicleUpdateEvent (cn.nukkit.event.vehicle.VehicleUpdateEvent)2 ItemBlock (cn.nukkit.item.ItemBlock)2 TranslationContainer (cn.nukkit.lang.TranslationContainer)2 Level (cn.nukkit.level.Level)2 Location (cn.nukkit.level.Location)2 AxisAlignedBB (cn.nukkit.math.AxisAlignedBB)2 NukkitRandom (cn.nukkit.math.NukkitRandom)2 Rail (cn.nukkit.utils.Rail)2