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

项目: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);
}
项目: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);
}
项目: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;
}
项目: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;
}