Search in sources :

Example 26 with Vector3

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

the class ObjectDarkOakTree method placeLeafAt.

private void placeLeafAt(ChunkManager worldIn, int x, int y, int z) {
    Vector3 blockpos = new Vector3(x, y, z);
    int material = worldIn.getBlockIdAt(blockpos.getFloorX(), blockpos.getFloorY(), blockpos.getFloorZ());
    if (material == Block.AIR) {
        this.setBlockAndNotifyAdequately(worldIn, blockpos, DARK_OAK_LEAVES);
    }
}
Also used : Vector3(cn.nukkit.math.Vector3)

Example 27 with Vector3

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

the class ObjectJungleBigTree method generate.

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;
    }
}
Also used : Vector3(cn.nukkit.math.Vector3)

Example 28 with Vector3

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

the class DarkOakTreePopulator 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 ObjectDarkOakTree().generate(level, random, v.setComponents(x, y, z));
    }
}
Also used : ObjectDarkOakTree(cn.nukkit.level.generator.object.tree.ObjectDarkOakTree) Vector3(cn.nukkit.math.Vector3)

Example 29 with Vector3

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

the class JungleTreePopulator 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 NewJungleTree(4 + random.nextBoundedInt(7)).generate(level, random, v.setComponents(x, y, z));
    }
}
Also used : NewJungleTree(cn.nukkit.level.generator.object.tree.NewJungleTree) Vector3(cn.nukkit.math.Vector3)

Example 30 with Vector3

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

the class MushroomPopulator 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 BigMushroom(type).generate(level, random, v.setComponents(x, y, z));
    }
}
Also used : BigMushroom(cn.nukkit.level.generator.object.mushroom.BigMushroom) Vector3(cn.nukkit.math.Vector3)

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