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); }
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; }
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; }