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

Java BlockGrowEvent类代码示例

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

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



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

示例1: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
        Block block = this.clone();
        if (this.meta / 4 < 2) {
            block.meta += 4;
            BlockGrowEvent ev = new BlockGrowEvent(this, block);
            Server.getInstance().getPluginManager().callEvent(ev);

            if (ev.isCancelled()) {
                return false;
            }
            this.getLevel().setBlock(this, ev.getNewState(), true, true);
        }

        this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
        item.count--;
        return true;
    }

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


示例2: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    //Bone meal
    if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
        BlockCrops block = (BlockCrops) this.clone();
        block.meta += new Random().nextInt(3) + 2;
        if (block.meta > 7) {
            block.meta = 7;
        }
        BlockGrowEvent ev = new BlockGrowEvent(this, block);
        Server.getInstance().getPluginManager().callEvent(ev);

        if (ev.isCancelled()) {
            return false;
        }

        this.getLevel().setBlock(this, ev.getNewState(), true, true);
        item.count--;

        return true;
    }

    return false;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:25,代码来源:BlockCrops.java


示例3: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal
        if (this.getSide(0).getId() != SUGARCANE_BLOCK) {
            for (y = 1; y < 3; ++y) {
                Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
                if (b.getId() == AIR) {
                    BlockGrowEvent ev = new BlockGrowEvent(b, new BlockSugarcane());
                    Server.getInstance().getPluginManager().callEvent(ev);
                    if (!ev.isCancelled()) {
                        this.getLevel().setBlock(b, ev.getNewState(), true);
                    }
                    break;
                }
            }
            this.meta = 0;
            this.getLevel().setBlock(this, this, true);
        }
        if ((player.gamemode & 0x01) == 0) {
            item.count--;
        }
        return true;
    }
    return false;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:26,代码来源:BlockSugarcane.java


示例4: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal
        int count = 1;

        for (int i = 1; i <= 2; i++) {
            int id = this.level.getBlockIdAt(this.getFloorX(), this.getFloorY() - i, this.getFloorZ());

            if (id == SUGARCANE_BLOCK) {
                count++;
            }
        }

        if (count < 3) {
            int toGrow = 3 - count;

            for (int i = 1; i <= toGrow; i++) {
                Block block = this.up(i);
                if (block.getId() == 0) {
                    BlockGrowEvent ev = new BlockGrowEvent(block, new BlockSugarcane());
                    Server.getInstance().getPluginManager().callEvent(ev);

                    if (!ev.isCancelled()) {
                        this.getLevel().setBlock(block, ev.getNewState(), true);
                    }
                } else if (block.getId() != SUGARCANE_BLOCK) {
                    break;
                }
            }
        }

        if ((player.gamemode & 0x01) == 0) {
            item.count--;
        }
        this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
        return true;
    }
    return false;
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:40,代码来源:BlockSugarcane.java


示例5: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    //Bone meal
    if (item.getId() == Item.DYE && item.getDamage() == 0x0f) {
        BlockCrops block = (BlockCrops) this.clone();
        if (this.meta < 7) {
            block.meta += new Random().nextInt(3) + 2;
            if (block.meta > 7) {
                block.meta = 7;
            }
            BlockGrowEvent ev = new BlockGrowEvent(this, block);
            Server.getInstance().getPluginManager().callEvent(ev);

            if (ev.isCancelled()) {
                return false;
            }

            this.getLevel().setBlock(this, ev.getNewState(), true, true);
        }

        this.level.addParticle(new BoneMealParticle(this.add(0.5, 0.5, 0.5)));
        item.count--;
        return true;
    }

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


示例6: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        if (this.down().getId() != FARMLAND) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(2) == 1) {
            if (this.meta < 0x07) {
                BlockCrops block = (BlockCrops) this.clone();
                ++block.meta;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

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


示例7: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        if (this.down().getId() != SOUL_SAND) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(10) == 1) {
            if (this.meta < 0x03) {
                BlockNetherWart block = (BlockNetherWart) this.clone();
                ++block.meta;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

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


示例8: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        Block down = down();
        if (down.getId() != SAND && down.getId() != CACTUS) {
            this.getLevel().useBreakOn(this);
        } else {
            for (int side = 2; side <= 5; ++side) {
                Block block = getSide(BlockFace.fromIndex(side));
                if (!block.canBeFlowedInto()) {
                    this.getLevel().useBreakOn(this);
                }
            }
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (down().getId() != CACTUS) {
            if (this.meta == 0x0F) {
                for (int y = 1; y < 3; ++y) {
                    Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
                    if (b.getId() == AIR) {
                        BlockGrowEvent event = new BlockGrowEvent(b, new BlockCactus());
                        Server.getInstance().getPluginManager().callEvent(event);
                        if (!event.isCancelled()) {
                            this.getLevel().setBlock(b, event.getNewState(), true);
                        }
                    }
                }
                this.meta = 0;
                this.getLevel().setBlock(this, this);
            } else {
                ++this.meta;
                this.getLevel().setBlock(this, this);
            }
        }
    }

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


示例9: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        int[] faces = new int[]{
                3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5
        };

        Block side = this.getSide(BlockFace.fromIndex(faces[this.meta]));

        if (side.getId() != Block.WOOD && side.getDamage() != BlockWood.JUNGLE) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(2) == 1) {
            if (this.meta / 4 < 2) {
                BlockCocoa block = (BlockCocoa) this.clone();
                block.meta += 4;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

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


示例10: onActivate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public boolean onActivate(Item item, Player player) {
    if (item.getId() == Item.DYE && item.getDamage() == 0x0F) { //Bonemeal
        Block base = this;
        // As sugarcane only grows to a height of three activating the
        // lowest or middle block should cause growing.  Here we drop
        // down one if it's not already the base.
        Block down = base.down();
        if (down.getId() == SUGARCANE_BLOCK) {
            base = down;
        }
        if (down.getId() != SUGARCANE_BLOCK) {
            for (int y = 1; y < 3; ++y) {
                Block b = base.getLevel().getBlock(new Vector3(base.x, base.y + y, base.z));
                if (b.getId() == AIR) {
                    BlockGrowEvent ev = new BlockGrowEvent(b, new BlockSugarcane());
                    Server.getInstance().getPluginManager().callEvent(ev);
                    if (!ev.isCancelled()) {
                        this.getLevel().setBlock(b, ev.getNewState(), true);
                    }
                } else if (b.getId() != SUGARCANE_BLOCK) {
                    break;
                }
            }
            base.meta = 0;
            base.getLevel().setBlock(base, base, true);
        }
        if ((player.gamemode & 0x01) == 0) {
            item.count--;
        }
        return true;
    }
    return false;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:35,代码来源:BlockSugarcane.java


示例11: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        int[] faces = new int[]{
                3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5
        };

        Block side = this.getSide(BlockFace.fromIndex(faces[this.meta]));

        if (side.getId() != Block.WOOD && side.getDamage() != BlockWood.JUNGLE) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(2) == 1) {
            if (this.meta <= 7) {
                BlockCocoa block = (BlockCocoa) this.clone();
                block.meta += 4;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

    return 0;
}
 
开发者ID:FrontierDevs,项目名称:Jenisys3,代码行数:35,代码来源:BlockCocoa.java


示例12: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        if (this.getSide(Vector3.SIDE_DOWN).getId() != FARMLAND) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(2) == 1) {
            if (this.meta < 0x07) {
                BlockCrops block = (BlockCrops) this.clone();
                ++block.meta;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

    return 0;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:29,代码来源:BlockCrops.java


示例13: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        Block down = getSide(0);
        if (down.getId() != SAND && down.getId() != CACTUS) {
            this.getLevel().useBreakOn(this);
        } else {
            for (int side = 2; side <= 5; ++side) {
                Block block = getSide(side);
                if (!block.canBeFlowedInto()) {
                    this.getLevel().useBreakOn(this);
                }
            }
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (getSide(0).getId() != CACTUS) {
            if (this.meta == 0x0F) {
                for (int y = 1; y < 3; ++y) {
                    Block b = this.getLevel().getBlock(new Vector3(this.x, this.y + y, this.z));
                    if (b.getId() == AIR) {
                        BlockGrowEvent event = new BlockGrowEvent(b, new BlockCactus());
                        Server.getInstance().getPluginManager().callEvent(event);
                        if (!event.isCancelled()) {
                            this.getLevel().setBlock(b, event.getNewState(), true);
                        }
                    }
                }
                this.meta = 0;
                this.getLevel().setBlock(this, this);
            } else {
                ++this.meta;
                this.getLevel().setBlock(this, this);
            }
        }
    }

    return 0;
}
 
开发者ID:Creeperface01,项目名称:NukkitGT,代码行数:39,代码来源:BlockCactus.java


示例14: onUpdate

import cn.nukkit.event.block.BlockGrowEvent; //导入依赖的package包/类
@Override
public int onUpdate(int type) {
    if (type == Level.BLOCK_UPDATE_NORMAL) {
        int[] faces = new int[]{
                3, 4, 2, 5, 3, 4, 2, 5, 3, 4, 2, 5
        };

        Block side = this.getSide(faces[this.meta]);

        if (side.getId() != Block.WOOD && side.getDamage() != BlockWood.JUNGLE) {
            this.getLevel().useBreakOn(this);
            return Level.BLOCK_UPDATE_NORMAL;
        }
    } else if (type == Level.BLOCK_UPDATE_RANDOM) {
        if (new Random().nextInt(2) == 1) {
            if (this.meta <= 7) {
                BlockCocoa block = (BlockCocoa) this.clone();
                block.meta += 4;
                BlockGrowEvent ev = new BlockGrowEvent(this, block);
                Server.getInstance().getPluginManager().callEvent(ev);

                if (!ev.isCancelled()) {
                    this.getLevel().setBlock(this, ev.getNewState(), true, true);
                } else {
                    return Level.BLOCK_UPDATE_RANDOM;
                }
            }
        } else {
            return Level.BLOCK_UPDATE_RANDOM;
        }
    }

    return 0;
}
 
开发者ID:NycuRO,项目名称:Apollo-OLD,代码行数:35,代码来源:BlockCocoa.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java ErrorReceiver类代码示例发布时间:2022-05-22
下一篇:
Java PutRecordsRequestEntry类代码示例发布时间: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