Java 类net.minecraft.server.DamageSource 实例源码

项目:CraftBukkit    文件:CraftEventFactory.java   
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityHuman) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage, boolean cancelOnZeroDamage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (cancelOnZeroDamage && event.getDamage() == 0);
}
项目:CraftBukkit    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.setIgnoreArmor();
    }

    // Check magic
    if (original.isMagic()) {
        newSource.setMagic();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
项目:Craftbukkit    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.setIgnoreArmor();
    }

    // Check magic
    if (original.isMagic()) {
        newSource.setMagic();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
项目:Almura-Server    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.j();
    }

    // Check magic
    if (original.q()) {
        newSource.r();
    }

    // Check fire
    if (original.c()) {
        newSource.l();
    }

    return newSource;
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static EntityDamageEvent handleLivingEntityDamageEvent(Entity damagee, DamageSource source, double rawDamage, double hardHatModifier, double blockingModifier, double armorModifier, double resistanceModifier, double magicModifier, double absorptionModifier, Function<Double, Double> hardHat, Function<Double, Double> blocking, Function<Double, Double> armor, Function<Double, Double> resistance, Function<Double, Double> magic, Function<Double, Double> absorption) {
    Map<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    Map<DamageModifier, Function<? super Double, Double>> modifierFunctions = new EnumMap<DamageModifier, Function<? super Double, Double>>(DamageModifier.class);
    modifiers.put(DamageModifier.BASE, rawDamage);
    modifierFunctions.put(DamageModifier.BASE, ZERO);
    if (source == DamageSource.FALLING_BLOCK || source == DamageSource.ANVIL) {
        modifiers.put(DamageModifier.HARD_HAT, hardHatModifier);
        modifierFunctions.put(DamageModifier.HARD_HAT, hardHat);
    }
    if (damagee instanceof EntityHuman) {
        modifiers.put(DamageModifier.BLOCKING, blockingModifier);
        modifierFunctions.put(DamageModifier.BLOCKING, blocking);
    }
    modifiers.put(DamageModifier.ARMOR, armorModifier);
    modifierFunctions.put(DamageModifier.ARMOR, armor);
    modifiers.put(DamageModifier.RESISTANCE, resistanceModifier);
    modifierFunctions.put(DamageModifier.RESISTANCE, resistance);
    modifiers.put(DamageModifier.MAGIC, magicModifier);
    modifierFunctions.put(DamageModifier.MAGIC, magic);
    modifiers.put(DamageModifier.ABSORPTION, absorptionModifier);
    modifierFunctions.put(DamageModifier.ABSORPTION, absorption);
    return handleEntityDamageEvent(damagee, source, modifiers, modifierFunctions);
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage, boolean cancelOnZeroDamage) {
    if (entity instanceof EntityEnderCrystal && !(source instanceof EntityDamageSource)) {
        return false;
    }

    final EnumMap<DamageModifier, Double> modifiers = new EnumMap<DamageModifier, Double>(DamageModifier.class);
    final EnumMap<DamageModifier, Function<? super Double, Double>> functions = new EnumMap(DamageModifier.class);

    modifiers.put(DamageModifier.BASE, damage);
    functions.put(DamageModifier.BASE, ZERO);

    final EntityDamageEvent event = handleEntityDamageEvent(entity, source, modifiers, functions);
    if (event == null) {
        return false;
    }
    return event.isCancelled() || (cancelOnZeroDamage && event.getDamage() == 0);
}
项目:Tweakkit-Server    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.setIgnoreArmor();
    }

    // Check magic
    if (original.isMagic()) {
        newSource.setMagic();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
项目:SpigotSource    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.setIgnoreArmor();
    }

    // Check magic
    if (original.isMagic()) {
        newSource.setMagic();
    }

    // Check fire
    if (original.isExplosion()) {
        newSource.setExplosion();
    }

    return newSource;
}
项目:Craft-city    文件:CraftDamageSource.java   
public static DamageSource copyOf(final DamageSource original) {
    CraftDamageSource newSource = new CraftDamageSource(original.translationIndex);

    // Check ignoresArmor
    if (original.ignoresArmor()) {
        newSource.j();
    }

    // Check magic
    if (original.q()) {
        newSource.r();
    }

    // Check fire
    if (original.c()) {
        newSource.l();
    }

    return newSource;
}
项目:CraftBukkit    文件:CraftLivingEntity.java   
public void setHealth(double health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth((float) health);
}
项目:CraftBukkit    文件:CraftLivingEntity.java   
public void damage(double amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    if (entity instanceof EntityEnderDragon) {
        ((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
    } else {
        entity.damageEntity(reason, (float) amount);
    }
}
项目:Craftbukkit    文件:CraftLivingEntity.java   
public void setHealth(double health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth((float) health);
}
项目:Craftbukkit    文件:CraftLivingEntity.java   
public void damage(double amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    entity.damageEntity(reason, (float) amount);
}
项目:Almura-Server    文件:CraftLivingEntity.java   
public void setHealth(double health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth((float) health);
}
项目:Almura-Server    文件:CraftLivingEntity.java   
public void damage(double amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    if (entity instanceof EntityEnderDragon) {
        ((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
    } else {
        entity.damageEntity(reason, (float) amount);
    }
}
项目:Almura-Server    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, float damage) {
    if (!(source instanceof EntityDamageSource)) {
        return false;
    }
    // We don't need to check for null, since EntityDamageSource will always return an event
    EntityDamageEvent event = handleEntityDamageEvent(entity, source, damage);
    return event.isCancelled() || event.getDamage() == 0;
}
项目:Tweakkit-Server    文件:CraftLivingEntity.java   
public void setHealth(double health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth((float) health);
}
项目:Tweakkit-Server    文件:CraftLivingEntity.java   
public void damage(double amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    if (entity instanceof EntityEnderDragon) {
        ((EntityEnderDragon) entity).dealDamage(reason, (float) amount);
    } else {
        entity.damageEntity(reason, (float) amount);
    }
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public void setHealth(double health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth((float) health);
}
项目:SpigotSource    文件:CraftLivingEntity.java   
public void damage(double amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    entity.damageEntity(reason, (float) amount);
}
项目:Craft-city    文件:CraftLivingEntity.java   
public void setHealth(int health) {
    if ((health < 0) || (health > getMaxHealth())) {
        throw new IllegalArgumentException("Health must be between 0 and " + getMaxHealth());
    }

    if (entity instanceof EntityPlayer && health == 0) {
        ((EntityPlayer) entity).die(DamageSource.GENERIC);
    }

    getHandle().setHealth(health);
}
项目:Craft-city    文件:CraftLivingEntity.java   
public void damage(int amount, org.bukkit.entity.Entity source) {
    DamageSource reason = DamageSource.GENERIC;

    if (source instanceof HumanEntity) {
        reason = DamageSource.playerAttack(((CraftHumanEntity) source).getHandle());
    } else if (source instanceof LivingEntity) {
        reason = DamageSource.mobAttack(((CraftLivingEntity) source).getHandle());
    }

    if (entity instanceof EntityEnderDragon) {
        ((EntityEnderDragon) entity).dealDamage(reason, amount);
    } else {
        entity.damageEntity(reason, amount);
    }
}
项目:Craft-city    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, int damage) {
    if (!(source instanceof EntityDamageSource)) {
        return false;
    }
    // We don't need to check for null, since EntityDamageSource will always return an event
    EntityDamageEvent event = handleEntityDamageEvent(entity, source, damage);
    return event.isCancelled() || event.getDamage() == 0;
}
项目:CraftBukkit    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    return handleNonLivingEntityDamageEvent(entity, source, damage, true);
}
项目:Tweakkit-Server    文件:CraftEventFactory.java   
public static boolean handleNonLivingEntityDamageEvent(Entity entity, DamageSource source, double damage) {
    return handleNonLivingEntityDamageEvent(entity, source, damage, true);
}