本文整理汇总了Java中cn.nukkit.event.block.BlockBreakEvent.setDrops方法的典型用法代码示例。如果您正苦于以下问题:Java BlockBreakEvent.setDrops方法的具体用法?Java BlockBreakEvent.setDrops怎么用?Java BlockBreakEvent.setDrops使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cn.nukkit.event.block.BlockBreakEvent
的用法示例。
在下文中一共展示了BlockBreakEvent.setDrops方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onBreak
import cn.nukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.LOWEST)
public void onBreak(BlockBreakEvent event) {
if (db.isMine(event.getBlock())) {
Block block = db.mineing(event.getBlock());
block.setLevel(event.getBlock().getLevel());
block.position(event.getBlock());
event.getPlayer().getInventory().addItem(event.getDrops());
event.setDrops(new Item[]{});
this.getServer().getScheduler().scheduleDelayedTask(
new BlockPlaceTask(this, Block.get(block.getId(), block.getDamage(), block)), 5);
}
}
示例2: onBlockBreak
import cn.nukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(priority = EventPriority.HIGH)
public void onBlockBreak(BlockBreakEvent event){
Player player = event.getPlayer();
if(player.isSurvival() && !(event.getInstaBreak() && event.isFastBreak()) && !ItemOwnership.getInstance().getData().containsKey(player.getName().toLowerCase()) && Utils.toBoolean(ItemOwnership.getInstance().getSetting().get("Enable").toString())){
Block block = event.getBlock();
Arrays.asList(event.getDrops()).forEach(item->new EntityOwnedItem(block.level.getChunk((int) block.getX() >> 4, (int) block.getZ() >> 4, true), new CompoundTag(){
{
putList(new ListTag<DoubleTag>("Pos"){
{
add(new DoubleTag("", block.getX() + 0.5));
add(new DoubleTag("", block.getY() + 0.5));
add(new DoubleTag("", block.getZ() + 0.5));
}
});
putList(new ListTag<DoubleTag>("Motion"){
{
add(new DoubleTag("", new Random().nextDouble() * 0.2 - 0.1));
add(new DoubleTag("", 0.2));
add(new DoubleTag("", new Random().nextDouble() * 0.2 - 0.1));
}
});
putList(new ListTag<FloatTag>("Rotation"){
{
add(new FloatTag("", new Random().nextFloat() * 360));
add(new FloatTag("", 0));
}
});
putShort("Health", 5);
putCompound("Item", (CompoundTag) NBTIO.putItemHelper(item).setName("Item"));
putShort("PickupDelay", 10);
}
}, player).spawnToAll());
event.setDrops(new Item[0]);
}
}
示例3: onBlockBreak
import cn.nukkit.event.block.BlockBreakEvent; //导入方法依赖的package包/类
@EventHandler(ignoreCancelled = true)
public void onBlockBreak(BlockBreakEvent event) {
if (!api.isDoTileDroPS(event.getBlock().getLevel())) {
event.setDrops(new Item[]{});
}
}