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


Java Player.isOnGround方法代码示例

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


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

示例1: getBreakTime

import cn.nukkit.Player; //导入方法依赖的package包/类
public double getBreakTime(Item item, Player player) {
    Objects.requireNonNull(item, "getBreakTime: Item can not be null");
    Objects.requireNonNull(player, "getBreakTime: Player can not be null");
    double blockHardness = getHardness();
    boolean correctTool = correctTool0(getToolType(), item);
    boolean canHarvestWithHand = canHarvestWithHand();
    int blockId = getId();
    int itemToolType = toolType0(item);
    int itemTier = item.getTier();
    int efficiencyLoreLevel = Optional.ofNullable(item.getEnchantment(Enchantment.ID_EFFICIENCY))
            .map(Enchantment::getLevel).orElse(0);
    int hasteEffectLevel = Optional.ofNullable(player.getEffect(Effect.HASTE))
            .map(Effect::getAmplifier).orElse(0);
    boolean insideOfWaterWithoutAquaAffinity = player.isInsideOfWater() &&
            Optional.ofNullable(player.getInventory().getHelmet().getEnchantment(Enchantment.ID_WATER_WORKER))
                    .map(Enchantment::getLevel).map(l -> l >= 1).orElse(false);
    boolean outOfWaterButNotOnGround = (!player.isInsideOfWater()) && (!player.isOnGround());
    return breakTime0(blockHardness, correctTool, canHarvestWithHand, blockId, itemToolType, itemTier,
            efficiencyLoreLevel, hasteEffectLevel, insideOfWaterWithoutAquaAffinity, outOfWaterButNotOnGround);
}
 
开发者ID:Rsplwe,项目名称:Nukkit-Java9,代码行数:21,代码来源:Block.java

示例2: run

import cn.nukkit.Player; //导入方法依赖的package包/类
public void run() {
    while (true) {
        try {
            for (Player player : Server.getInstance().getOnlinePlayers().values()) {
                if(!player.isOnGround()){
                    double y = player.y;
                    boolean flag = false;
                    thread.sleep(5*1000);
                    if(player.y == y){
                        flag = true;
                    }
                    if(player.y >= y) {
                        y = player.y;
                        if (player.move(0, -3, 0)) {
                            if (player.move(0, -3, 0)) {
                                if (player.y + 6 == y) {
                                    flag = true;
                                }
                            }
                        }
                    }
                    if(flag){
                        player.setMotion(new Vector3(0,0,0));
                        player.teleport(player);
                        if(Flycount.containsKey(player.getName())){
                            if(Flycount.get(player.getName()) > 5){
                                player.kick(TextFormat.AQUA+"Cheat Type: "+TextFormat.RED+"Fly");
                            }
                            Flycount.put(player.getName(),Flycount.get(player.getName())+1);
                        }else{
                            Flycount.put(player.getName(),1);
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
 
开发者ID:WetABQ,项目名称:Nukkit-AntiCheat,代码行数:41,代码来源:AntiFlyThread.java


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