Examples of DamageType


Examples of org.spout.vanilla.event.cause.DamageCause.DamageType

  public int getBaseProtection() {
    return protection;
  }

  public int getProtection(ItemStack item, DamageCause<?> cause) {
    DamageType type = cause.getType();
    int amount = 0;
    int level = 0;
    // Armor can only have one of these protection enchantments
    if (Enchantment.hasEnchantment(item, VanillaEnchantments.PROTECTION) && (type != DamageType.COMMAND && type != DamageType.VOID)) {
      level = Enchantment.getEnchantmentLevel(item, VanillaEnchantments.PROTECTION);
    } else if (Enchantment.hasEnchantment(item, VanillaEnchantments.BLAST_PROTECTION) && type.equals(DamageType.EXPLOSION)) {
      level = Enchantment.getEnchantmentLevel(item, VanillaEnchantments.BLAST_PROTECTION);
    } else if (Enchantment.hasEnchantment(item, VanillaEnchantments.FIRE_PROTECTION) && (type == DamageType.BURN && type == DamageType.FIRE_SOURCE)) {
      level = Enchantment.getEnchantmentLevel(item, VanillaEnchantments.FIRE_PROTECTION);
    } else if (Enchantment.hasEnchantment(item, VanillaEnchantments.PROJECTILE_PROTECTION) && (type == DamageType.PROJECTILE && type == DamageType.FIREBALL)) {
      level = Enchantment.getEnchantmentLevel(item, VanillaEnchantments.PROJECTILE_PROTECTION);
    }
    amount += level * 3;

    // Feather Falling is compatible with all of the above enchantments
    if (Enchantment.hasEnchantment(item, VanillaEnchantments.FEATHER_FALLING) && type.equals(DamageType.FALL)) {
      amount += Enchantment.getEnchantmentLevel(item, VanillaEnchantments.FEATHER_FALLING);
    }

    return amount;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.