Java Code Examples for cn.nukkit.Player#isOnGround()

The following examples show how to use cn.nukkit.Player#isOnGround() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Block.java    From Jupiter with GNU General Public License v3.0 6 votes vote down vote up
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);
}
 
Example 2
Source File: Block.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
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();

    if (blockHardness == 0) {
        return 0;
    }

    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);
}
 
Example 3
Source File: Block.java    From Nukkit with GNU General Public License v3.0 6 votes vote down vote up
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);
}