当前位置: 首页>>代码示例>>Java>>正文


Java NukkitRandom.nextBoundedInt方法代码示例

本文整理汇总了Java中cn.nukkit.math.NukkitRandom.nextBoundedInt方法的典型用法代码示例。如果您正苦于以下问题:Java NukkitRandom.nextBoundedInt方法的具体用法?Java NukkitRandom.nextBoundedInt怎么用?Java NukkitRandom.nextBoundedInt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在cn.nukkit.math.NukkitRandom的用法示例。


在下文中一共展示了NukkitRandom.nextBoundedInt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: placeObject

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {

        this.placeTrunk(level, x, y, z, random, this.getTreeHeight() - 1);

        for (int yy = y - 3 + this.getTreeHeight(); yy <= y + this.getTreeHeight(); ++yy) {
            double yOff = yy - (y + this.getTreeHeight());
            int mid = (int) (1 - yOff / 2);
            for (int xx = x - mid; xx <= x + mid; ++xx) {
                int xOff = Math.abs(xx - x);
                for (int zz = z - mid; zz <= z + mid; ++zz) {
                    int zOff = Math.abs(zz - z);
                    if (xOff == mid && zOff == mid && (yOff == 0 || random.nextBoundedInt(2) == 0)) {
                        continue;
                    }
                    if (!Block.solid[level.getBlockIdAt(xx, yy, zz)]) {

                        level.setBlockIdAt(xx, yy, zz, this.getLeafBlock());
                        level.setBlockDataAt(xx, yy, zz, this.getType());
                    }
                }
            }
        }
    }
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:24,代码来源:ObjectTree.java

示例2: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:17,代码来源:SwampTreePopulator.java

示例3: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:18,代码来源:DarkOakTreePopulator.java

示例4: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:17,代码来源:JungleBigTreePopulator.java

示例5: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canTallGrassStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y, z, 2);
            this.level.setBlockIdAt(x, y + 1, z, Block.DOUBLE_PLANT);
            this.level.setBlockDataAt(x, y + 1, z, 10);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:18,代码来源:PopulatorTallGrass.java

示例6: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:17,代码来源:SavannaTreePopulator.java

示例7: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:17,代码来源:JungleTreePopulator.java

示例8: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@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));
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:17,代码来源:MushroomPopulator.java

示例9: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canSugarcaneStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.SUGARCANE_BLOCK);
            this.level.setBlockDataAt(x, y, z, 1);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:16,代码来源:PopulatorSugarcane.java

示例10: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canCactusStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.CACTUS);
            this.level.setBlockDataAt(x, y, z, 1);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:PopulatorCactus.java

示例11: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canGrassStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.TALL_GRASS);
            this.level.setBlockDataAt(x, y, z, 0);
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:16,代码来源:PopulatorGrass.java

示例12: populate

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    int amount = random.nextBoundedInt(this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = NukkitMath.randomRange(random, chunkX * 16, chunkX * 16 + 15);
        int z = NukkitMath.randomRange(random, chunkZ * 16, chunkZ * 16 + 15);
        int y = this.getHighestWorkableBlock(x, z);

        if (y != -1 && this.canLilyPadStay(x, y, z)) {
            this.level.setBlockIdAt(x, y, z, Block.WATER_LILY);
            this.level.setBlockDataAt(x, y, z, 1);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:16,代码来源:PopulatorLilyPad.java

示例13: placeObject

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
    this.treeHeight = random.nextBoundedInt(3) + 4;
    super.placeObject(level, x, y, z, random);
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:6,代码来源:ObjectOakTree.java

示例14: placeObject

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
@Override
public void placeObject(ChunkManager level, int x, int y, int z, NukkitRandom random) {
    this.treeHeight = random.nextBoundedInt(6) + 4;
    super.placeObject(level, x, y, z, random);
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:6,代码来源:ObjectJungleTree.java

示例15: placeVine

import cn.nukkit.math.NukkitRandom; //导入方法依赖的package包/类
private void placeVine(ChunkManager level, NukkitRandom random, Vector3 pos, int meta) {
    if (random.nextBoundedInt(3) > 0 && level.getBlockIdAt((int) pos.x, (int) pos.y, (int) pos.z) == 0) {
        this.setBlockAndNotifyAdequately(level, pos, new BlockVine(meta));
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:6,代码来源:NewJungleBigTree.java


注:本文中的cn.nukkit.math.NukkitRandom.nextBoundedInt方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。