• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java ChunkManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中cn.nukkit.level.ChunkManager的典型用法代码示例。如果您正苦于以下问题:Java ChunkManager类的具体用法?Java ChunkManager怎么用?Java ChunkManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ChunkManager类属于cn.nukkit.level包,在下文中一共展示了ChunkManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
    int bx = chunkX << 4;
    int bz = chunkZ << 4;
    int tx = bx + 15;
    int tz = bz + 15;
    ObjectOre ore = new ObjectOre(random, type, Block.AIR);
    for (int i = 0; i < ore.type.clusterCount; ++i) {
        int x = random.nextRange(0, 15);
        int z = random.nextRange(0, 15);
        int y = this.getHighestWorkableBlock(chunk, x, z);
        if (y != -1) {
            ore.placeObject(level, bx + x, y, bz + z);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:19,代码来源:PopulatorGlowStone.java


示例2: placeObject

import cn.nukkit.level.ChunkManager; //导入依赖的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:CoreXDevelopment,项目名称:CoreX,代码行数:24,代码来源:ObjectTree.java


示例3: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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:Rsplwe,项目名称:Nukkit-Java9,代码行数:17,代码来源:JungleTreePopulator.java


示例4: growLeavesLayer

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
/**
 * 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);
                }
            }
        }
    }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:20,代码来源:HugeTreesGenerator.java


示例5: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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


示例6: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = new Random();
    this.random.setSeed(level.getSeed());
    long worldLong1 = this.random.nextLong();
    long worldLong2 = this.random.nextLong();

    int size = this.checkAreaSize;

    for (int x = chunkX - size; x <= chunkX + size; x++)
        for (int z = chunkZ - size; z <= chunkZ + size; z++) {
            long randomX = x * worldLong1;
            long randomZ = z * worldLong2;
            this.random.setSeed(randomX ^ randomZ ^ level.getSeed());
            generateChunk(x, z, level.getChunk(chunkX, chunkZ));
        }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:18,代码来源:PopulatorCaves.java


示例7: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.level = level;
    BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
    int bx = chunkX << 4;
    int bz = chunkZ << 4;
    int tx = bx + 15;
    int tz = bz + 15;
    int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
    for (int i = 0; i < amount; ++i) {
        int x = random.nextRange(0, 15);
        int z = random.nextRange(0, 15);
        int y = this.getHighestWorkableBlock(chunk, x, z);
        if (y != -1 && this.canGroundFireStay(chunk, x, y, z)) {
            chunk.setBlock(x, y, z, Block.FIRE);
            chunk.setBlockLight(x, y, z, Block.light[Block.FIRE]);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:20,代码来源:PopulatorGroundFire.java


示例8: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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;

    if (flowerTypes.size() == 0) {
        this.addType(Block.RED_FLOWER, BlockFlower.TYPE_POPPY);
        this.addType(Block.DANDELION, 0);
    }

    int endNum = this.flowerTypes.size();

    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.canFlowerStay(x, y, z)) {
            int[] type = this.flowerTypes.get(random.nextRange(0, endNum - 1));
            this.level.setBlockIdAt(x, y, z, type[0]);
            this.level.setBlockDataAt(x, y, z, type[1]);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:26,代码来源:PopulatorFlower.java


示例9: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = new Random();
    this.random.setSeed(level.getSeed());
    worldLong1 = this.random.nextLong();
    worldLong2 = this.random.nextLong();

    int i = this.checkAreaSize;

    for (int x = chunkX - i; x <= chunkX + i; x++)
        for (int z = chunkZ - i; z <= chunkZ + i; z++) {
            long l3 = x * worldLong1;
            long l4 = z * worldLong2;
            this.random.setSeed(l3 ^ l4 ^ level.getSeed());
            generateChunk(chunkX, chunkZ, level.getChunk(chunkX, chunkZ));
        }
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:18,代码来源:PopulatorRavines.java


示例10: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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 NewSavannaTree().generate(level, random, v.setComponents(x, y, z));
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:17,代码来源:SavannaTreePopulator.java


示例11: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    this.random = random;
    if (random.nextRange(0, 100) < 5) {
        this.level = level;
        int amount = random.nextRange(0, this.randomAmount + 1) + this.baseAmount;
        BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
        int bx = chunkX << 4;
        int bz = chunkZ << 4;
        int tx = bx + 15;
        int tz = bz + 15;
        for (int i = 0; i < amount; ++i) {
            int x = random.nextRange(0, 15);
            int z = random.nextRange(0, 15);
            int y = this.getHighestWorkableBlock(chunk, x, z);
            if (y != -1 && chunk.getBlockId(x, y, z) == Block.AIR) {
                chunk.setBlock(x, y, z, Block.LAVA);
                chunk.setBlockLight(x, y, z, Block.light[Block.LAVA]);
                this.lavaSpread(bx + x, y, bz + z);
            }
        }
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:24,代码来源:PopulatorLava.java


示例12: addHangingVine

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
private void addHangingVine(ChunkManager worldIn, BlockVector3 pos, int meta) {
    this.addVine(worldIn, pos, meta);
    int i = 4;

    for (pos = pos.down(); i > 0 && worldIn.getBlockIdAt(pos.x, pos.y, pos.z) == Block.AIR; --i) {
        this.addVine(worldIn, pos, meta);
        pos = pos.down();
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:10,代码来源:NewJungleTree.java


示例13: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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:CoreXDevelopment,项目名称:CoreX,代码行数:17,代码来源:SwampTreePopulator.java


示例14: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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:CoreXDevelopment,项目名称:CoreX,代码行数:18,代码来源:DarkOakTreePopulator.java


示例15: growGrass

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
public static void growGrass(ChunkManager level, Vector3 pos, NukkitRandom random, int count, int radius) {
    int[][] arr = {
            {Block.DANDELION, 0},
            {Block.POPPY, 0},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1},
            {Block.TALL_GRASS, 1}
    };
    int arrC = arr.length - 1;
    for (int c = 0; c < count; c++) {
        int x = random.nextRange((int) (pos.x - radius), (int) (pos.x + radius));
        int z = random.nextRange((int) (pos.z) - radius, (int) (pos.z + radius));

        if (level.getBlockIdAt(x, (int) (pos.y + 1), z) == Block.AIR && level.getBlockIdAt(x, (int) (pos.y), z) == Block.GRASS) {
            int[] t = arr[random.nextRange(0, arrC)];
            level.setBlockIdAt(x, (int) (pos.y + 1), z, t[0]);
            level.setBlockDataAt(x, (int) (pos.y + 1), z, t[1]);
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:22,代码来源:ObjectTallGrass.java


示例16: populate

import cn.nukkit.level.ChunkManager; //导入依赖的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 NewSwampTree().generate(level, random, v.setComponents(x, y, z));
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:17,代码来源:SwampTreePopulator.java


示例17: init

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void init(ChunkManager level, NukkitRandom random) {
    this.level = level;
    this.nukkitRandom = random;
    this.random = new Random();
    this.nukkitRandom.setSeed(this.level.getSeed());
    this.noiseBase = new Simplex(this.nukkitRandom, 4, 1 / 4f, 1 / 64f);
    this.nukkitRandom.setSeed(this.level.getSeed());
    this.localSeed1 = this.random.nextLong();
    this.localSeed2 = this.random.nextLong();
    PopulatorOre ores = new PopulatorOre(Block.NETHERRACK);
    ores.setOreTypes(new OreType[]{
            new OreType(new BlockOreQuartz(), 20, 16, 0, 128),
            new OreType(new BlockSoulSand(), 5, 64, 0, 128),
            new OreType(new BlockGravel(), 5, 64, 0, 128),
            new OreType(new BlockLava(), 1, 16, 0, (int) this.waterHeight),
    });
    this.populators.add(ores);
    this.populators.add(new PopulatorGlowStone());
    PopulatorGroundFire groundFire = new PopulatorGroundFire();
    groundFire.setBaseAmount(1);
    groundFire.setRandomAmount(1);
    this.populators.add(groundFire);
    PopulatorLava lava = new PopulatorLava();
    lava.setBaseAmount(0);
    lava.setRandomAmount(2);
    this.populators.add(lava);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:29,代码来源:Nether.java


示例18: isSpaceAt

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
/**
 * returns whether or not there is space for a tree to grow at a certain position
 */
private boolean isSpaceAt(ChunkManager worldIn, Vector3 leavesPos, int height) {
    boolean flag = true;

    if (leavesPos.getY() >= 1 && leavesPos.getY() + height + 1 <= 256) {
        for (int i = 0; i <= 1 + height; ++i) {
            int j = 2;

            if (i == 0) {
                j = 1;
            } else if (i >= 1 + height - 2) {
                j = 2;
            }

            for (int k = -j; k <= j && flag; ++k) {
                for (int l = -j; l <= j && flag; ++l) {
                    Vector3 blockPos = leavesPos.add(k, i, l);
                    if (leavesPos.getY() + i < 0 || leavesPos.getY() + i >= 256 || !this.canGrowInto(worldIn.getBlockIdAt((int) blockPos.x, (int) blockPos.y, (int) blockPos.z))) {
                        flag = false;
                    }
                }
            }
        }

        return flag;
    } else {
        return false;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:32,代码来源:HugeTreesGenerator.java


示例19: ensureDirtsUnderneath

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
/**
 * returns whether or not there is dirt underneath the block where the tree will be grown.
 * It also generates dirt around the block in a 2x2 square if there is dirt underneath the blockpos.
 */
private boolean ensureDirtsUnderneath(Vector3 pos, ChunkManager worldIn) {
    Vector3 blockpos = pos.down();
    int block = worldIn.getBlockIdAt((int) blockpos.x, (int) blockpos.y, (int) blockpos.z);

    if ((block == Block.GRASS || block == Block.DIRT) && pos.getY() >= 2) {
        this.setDirtAt(worldIn, blockpos);
        this.setDirtAt(worldIn, blockpos.east());
        this.setDirtAt(worldIn, blockpos.south());
        this.setDirtAt(worldIn, blockpos.south().east());
        return true;
    } else {
        return false;
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:19,代码来源:HugeTreesGenerator.java


示例20: populate

import cn.nukkit.level.ChunkManager; //导入依赖的package包/类
@Override
public void populate(ChunkManager level, int chunkX, int chunkZ, NukkitRandom random) {
    FullChunk chunk = level.getChunk(chunkX, chunkZ);
    for (int x = 0; x < 16; ++x) {
        for (int z = 0; z < 16; ++z) {
            Biome biome = Biome.getBiome(chunk.getBiomeId(x, z));
            Block[] cover = biome.getGroundCover();
            if (cover != null && cover.length > 0) {
                int diffY = 0;
                if (!cover[0].isSolid()) {
                    diffY = 1;
                }

                byte[] column = chunk.getBlockIdColumn(x, z);
                int y;
                for (y = 127; y > 0; --y) {
                    if (column[y] != 0x00 && !Block.get(column[y] & 0xff).isTransparent()) {
                        break;
                    }
                }
                int startY = Math.min(127, y + diffY);
                int endY = startY - cover.length;
                for (y = startY; y > endY && y >= 0; --y) {
                    Block b = cover[startY - y];
                    if (column[y] == 0x00 && b.isSolid()) {
                        break;
                    }
                    if (b.getDamage() == 0) {
                        chunk.setBlockId(x, y, z, b.getId());
                    } else {
                        chunk.setBlock(x, y, z, b.getId(), b.getDamage());
                    }
                }
            }
        }
    }
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:38,代码来源:PopulatorGroundCover.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java DefaultLineRenderer2D类代码示例发布时间:2022-05-22
下一篇:
Java StringValue类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap