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


Java ObjectTree.growTree方法代码示例

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


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

示例1: onActivate

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //BoneMeal
        if ((player.gamemode & 0x01) == 0) {
            item.count--;
        }

        if (this.level.rand.nextFloat() >= 0.45) {
            this.level.addParticle(new BoneMealParticle(this));
            return true;
        }

        ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.meta & 0x07);
        return true;
    }
    this.getLevel().loadChunk((int) this.x >> 4, (int) this.z >> 4);
    return false;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:18,代码来源:BlockSapling.java

示例2: onUpdate

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        if (this.down().isTransparent()) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) { //Growth
        if (new NukkitRandom().nextRange(1, 7) == 1) {
            if ((this.meta & 0x08) == 0x08) {
                ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.meta & 0x07);
            } else {
                this.meta |= 0x08;
                this.getLevel().setBlock(this, this, true);
                return Level.BLOCK_UPDATE_RANDOM;
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }
    return 1;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:22,代码来源:BlockSapling.java

示例3: onUpdate

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        if (this.getSide(0).isTransparent()) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) { //Growth
        if (new NukkitRandom().nextRange(1, 7) == 1) {
            if ((this.meta & 0x08) == 0x08) {
                ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.meta & 0x07);
            } else {
                this.meta |= 0x08;
                this.getLevel().setBlock(this, this, true);
                return Level.BLOCK_UPDATE_RANDOM;
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }
    return 1;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:22,代码来源:BlockSapling.java

示例4: generateChunk

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
@Override
public void generateChunk(int chunkX, int chunkZ) {
	BaseFullChunk chunk = level.getChunk(chunkX, chunkZ);
	if (chunkX % 20 == 0 && chunkZ % 20 == 0) {
		for (int x = 0; x < 16; x++) {
			for (int z = 0; z < 16; z++) {
				chunk.setBlock(x, 0, z, Block.BEDROCK);
				for (int y = 1; y <= 3; y++) {
					chunk.setBlock(x, y, z, Block.STONE);
				}
				chunk.setBlock(x, 4, z, Block.DIRT);
				chunk.setBlock(x, 5, z, Block.GRASS);
			}
		}
		ObjectTree.growTree(level, chunkX*16 + 8, 6, chunkZ*16 + 8, random, BlockSapling.OAK);
		if (DataBase.getInstance().config.getBoolean("create-sponge", false)) {
			chunk.setBlock(3, 6, 3, Block.SPONGE);
			chunk.setBlock(3, 7, 3, Block.STONE);
		}
	}
}
 
开发者ID:MCFT-Server,项目名称:Mskyblock,代码行数:22,代码来源:SkyblockGenerator.java

示例5: populate

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的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 << 4, (chunkX << 4) + 15);
        int z = NukkitMath.randomRange(random, chunkZ << 4, (chunkZ << 4) + 15);
        int y = this.getHighestWorkableBlock(x, z);
        if (y == -1) {
            continue;
        }
        ObjectTree.growTree(this.level, x, y, z, random, this.type);
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:15,代码来源:PopulatorTree.java

示例6: onActivate

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //BoneMeal
        ObjectTree.growTree(this.getLevel(), (int) this.x, (int) this.y, (int) this.z, new NukkitRandom(), this.meta & 0x07);
        if ((player.gamemode & 0x01) == 0) {
            item.count--;
        }

        return true;
    }
    this.getLevel().loadChunk((int) this.x >> 4, (int) this.z >> 4);
    return false;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:13,代码来源:BlockSapling.java

示例7: createIsland

import cn.nukkit.level.generator.object.tree.ObjectTree; //导入方法依赖的package包/类
private void createIsland(Player p, Position pos) {
    int groundHeight = pos.getFloorY();
    int X = pos.getFloorX();
    int Z = pos.getFloorZ();
    Level world = pos.level;
    // bedrock - ensures island are not overwritten
    for (int x = X; x < X + 1; ++x) {
        for (int z = Z; z < Z + 1; ++z) {
            world.setBlockIdAt(x, groundHeight, z, Block.BEDROCK);
        }
    }
    // Add some dirt and grass
    for (int x = X - 1; x < X + 3; ++x) {
        for (int z = X - 1; z < X + 3; ++z) {
            world.setBlockIdAt(x, groundHeight + 1, z, Block.DIRT);
            world.setBlockIdAt(x, groundHeight + 2, z, Block.DIRT);
        }
    }
    for (int x = X - 2; x < X + 4; ++x) {
        for (int z = Z - 2; z < Z + 4; ++z) {
            world.setBlockIdAt(x, groundHeight + 3, z, Block.DIRT);
            world.setBlockIdAt(x, groundHeight + 4, z, Block.DIRT);
        }
    }
    for (int x = X - 3; x < X + 5; ++x) {
        for (int z = Z - 3; z < Z + 5; ++z) {
            world.setBlockIdAt(x, groundHeight + 5, z, Block.DIRT);
            world.setBlockIdAt(x, groundHeight + 6, z, Block.DIRT);
            world.setBlockIdAt(x, groundHeight + 7, z, Block.GRASS);
        }
    }
    // Then cut off the corners to make it round-ish
    for (int x_space = X - 2; x_space <= X + 2; x_space += 4) {
        for (int z_space = Z - 2; z_space <= Z + 2; z_space += 4) {
            world.setBlockIdAt(x_space, groundHeight + 3, z_space, Block.AIR);
            world.setBlockIdAt(x_space, groundHeight + 4, z_space, Block.AIR);
        }
    }

    for (int y = groundHeight - 1; y < groundHeight + 8; ++y) {
        for (int x_space = X - 3; x_space <= X + 3; x_space += 6) {
            for (int z_space = -3; z_space <= Z + 3; z_space += 6) {
                world.setBlockIdAt(x_space, y, z_space, Block.AIR);
            }
        }
    }
    int Xt = X;
    int Zt = Z;
    // First place
    world.setBlockIdAt(Xt - 1, groundHeight + 1, Zt + 1, Block.AIR);
    world.setBlockIdAt(Xt - 2, groundHeight + 1, Zt + 2, Block.AIR);
    world.setBlockIdAt(Xt - 1, groundHeight + 1, Zt - 1, Block.AIR);
    world.setBlockIdAt(Xt - 2, groundHeight + 1, Zt - 2, Block.AIR);
    // tree
    ObjectTree.growTree(world, X + 10, groundHeight + 8, Z + 11, new NukkitRandom(), BlockSapling.OAK);
    this.initChest(world, X, groundHeight, Z, p);
}
 
开发者ID:TheSolidCrafter,项目名称:ASkyBlock-Nukkit,代码行数:58,代码来源:SchematicHandler.java


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