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


Java Block.TALL_GRASS属性代码示例

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


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

示例1: growGrass

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,代码行数:21,代码来源:ObjectTallGrass.java

示例2: initEntity

@Override
protected void initEntity() {
    super.initEntity();

    this.setHealth(4);
    this.setMaxHealth(4);

    this.state = 2;
    this.liveTime = this.level.rand.nextInt(3) + 1;

    if (isEffect && this.level.gameRules.getBoolean("doFireTick") && (this.server.getDifficulty() >= 2)) {
        Block block = this.getLevelBlock();
        if (block.getId() == 0 || block.getId() == Block.TALL_GRASS) {
            BlockFire fire = new BlockFire();
            fire.x = block.x;
            fire.y = block.y;
            fire.z = block.z;
            fire.level = level;
            this.getLevel().setBlock(fire, fire, true);
            if (fire.isBlockTopFacingSurfaceSolid(fire.down()) || fire.canNeighborBurn()) {

                BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING);
                getServer().getPluginManager().callEvent(e);

                if (!e.isCancelled()) {
                    level.setBlock(fire, fire, true);
                    level.scheduleUpdate(fire, fire.tickRate() + level.rand.nextInt(10));
                }
            }
        }
    }
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:32,代码来源:EntityLightning.java

示例3: initEntity

@Override
protected void initEntity() {
    super.initEntity();

    this.setHealth(4);
    this.setMaxHealth(4);

    this.state = 2;
    this.liveTime = this.level.rand.nextInt(3) + 1;

    if (isEffect && this.level.gameRules.getBoolean("dofiretick") && (this.server.getDifficulty() >= 2)) {
        Block block = this.getLevelBlock();
        if (block.getId() == 0 || block.getId() == Block.TALL_GRASS) {
            BlockFire fire = new BlockFire();
            fire.x = block.x;
            fire.y = block.y;
            fire.z = block.z;
            fire.level = level;
            this.getLevel().setBlock(fire, fire, true);
            if (fire.isBlockTopFacingSurfaceSolid(fire.down()) || fire.canNeighborBurn()) {

                BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING);
                getServer().getPluginManager().callEvent(e);

                if (!e.isCancelled()) {
                    level.setBlock(fire, fire, true);
                    level.scheduleUpdate(fire, fire.tickRate() + level.rand.nextInt(10));
                }
            }
        }
    }
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:32,代码来源:EntityLightning.java

示例4: onUpdate

@Override
public boolean onUpdate(int currentTick) {
    if (this.closed) {
        return false;
    }

    int tickDiff = currentTick - this.lastUpdate;

    if (tickDiff <= 0 && !this.justCreated) {
        return true;
    }

    this.lastUpdate = currentTick;

    this.entityBaseTick(tickDiff);

    if (this.state == 2) {
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_THUNDER, 93, -1, this);
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_EXPLODE, 93, -1, this);
    }

    this.state--;

    if (this.state < 0) {
        if (this.liveTime == 0) {
            this.close();
            return false;
        } else if (this.state < -this.level.rand.nextInt(10)) {
            this.liveTime--;
            this.state = 1;

            if (this.isEffect && this.level.gameRules.getBoolean("doFireTick")) {
                Block block = this.getLevelBlock();

                if (block.getId() == Block.AIR || block.getId() == Block.TALL_GRASS) {
                    BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING);
                    getServer().getPluginManager().callEvent(e);

                    if (!e.isCancelled()) {
                        Block fire = new BlockFire();
                        this.level.setBlock(block, fire);
                        this.getLevel().scheduleUpdate(fire, fire.tickRate());
                    }
                }
            }
        }
    }

    if (this.state >= 0) {
        if (this.isEffect) {
            AxisAlignedBB bb = getBoundingBox().grow(3, 3, 3);
            bb.maxX += 6;

            for (Entity entity : this.level.getCollidingEntities(bb, this)) {
                entity.onStruckByLightning(this);
            }
        }
    }

    return true;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:61,代码来源:EntityLightning.java

示例5: onUpdate

@Override
public boolean onUpdate(int currentTick) {
    if (this.closed) {
        return false;
    }

    int tickDiff = currentTick - this.lastUpdate;

    if (tickDiff <= 0 && !this.justCreated) {
        return true;
    }

    this.lastUpdate = currentTick;

    this.entityBaseTick(tickDiff);

    if (this.state == 2) {
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_THUNDER, 93, -1, this);
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_EXPLODE, 93, -1, this);
    }

    this.state--;

    if (this.state < 0) {
        if (this.liveTime == 0) {
            this.close();
            return false;
        } else if (this.state < -this.level.rand.nextInt(10)) {
            this.liveTime--;
            this.state = 1;

            if (this.isEffect && this.level.gameRules.getBoolean("dofiretick")) {
                Block block = this.getLevelBlock();

                if (block.getId() == Block.AIR || block.getId() == Block.TALL_GRASS) {
                    BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING);
                    getServer().getPluginManager().callEvent(e);

                    if (!e.isCancelled()) {
                        Block fire = new BlockFire();
                        this.level.setBlock(block, fire);
                        this.getLevel().scheduleUpdate(fire, fire.tickRate());
                    }
                }
            }
        }
    }

    if (this.state >= 0) {
        if (this.isEffect) {
            AxisAlignedBB bb = getBoundingBox().grow(3, 3, 3);
            bb.maxX += 6;

            for (Entity entity : this.level.getCollidingEntities(bb, this)) {
                entity.onStruckByLightning(this);
            }
        }
    }

    return true;
}
 
开发者ID:JupiterDevelopmentTeam,项目名称:Jupiter,代码行数:61,代码来源:EntityLightning.java

示例6: onUpdate

@Override
public boolean onUpdate(int currentTick) {
    if (this.closed) {
        return false;
    }

    int tickDiff = currentTick - this.lastUpdate;

    if (tickDiff <= 0 && !this.justCreated) {
        return true;
    }

    this.lastUpdate = currentTick;

    this.entityBaseTick(tickDiff);

    if (this.state == 2) {
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_THUNDER, 93, -1, this, false, false);
        this.level.addLevelSoundEvent(LevelSoundEventPacket.SOUND_EXPLODE, 93, -1, this, false, false);
    }

    this.state--;

    if (this.state < 0) {
        if (this.liveTime == 0) {
            this.close();
            return false;
        } else if (this.state < -this.level.rand.nextInt(10)) {
            this.liveTime--;
            this.state = 1;

            if (this.isEffect && this.level.gameRules.getBoolean("doFireTick")) {
                Block block = this.getLevelBlock();

                if (block.getId() == Block.AIR || block.getId() == Block.TALL_GRASS) {
                    BlockIgniteEvent e = new BlockIgniteEvent(block, null, this, BlockIgniteEvent.BlockIgniteCause.LIGHTNING);
                    getServer().getPluginManager().callEvent(e);

                    if (!e.isCancelled()) {
                        Block fire = new BlockFire();
                        this.level.setBlock(block, fire);
                        this.getLevel().scheduleUpdate(fire, fire.tickRate());
                    }
                }
            }
        }
    }

    if (this.state >= 0) {
        if (this.isEffect) {
            AxisAlignedBB bb = getBoundingBox().grow(3, 3, 3);
            bb.maxX += 6;

            for (Entity entity : this.level.getCollidingEntities(bb, this)) {
                entity.onStruckByLightning(this);
            }
        }
    }

    return true;
}
 
开发者ID:CoreXDevelopment,项目名称:CoreX,代码行数:61,代码来源:EntityLightning.java


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