當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。