public static Optional<Tuple<DamageModifier, Function<? super Double, Double>>>
     createAbsorptionModifier(EntityLivingBase entityLivingBase, DamageSource damageSource) {
   if (entityLivingBase.isPotionActive(Potion.absorption)) {
     Function<? super Double, Double> function =
         damage ->
             -(Math.max(
                 damage - Math.max(damage - entityLivingBase.getAbsorptionAmount(), 0.0F), 0.0F));
     DamageModifier modifier =
         DamageModifier.builder()
             .cause(
                 Cause.of(
                     NamedCause.of(
                         DamageEntityEvent.ABSORPTION,
                         entityLivingBase.getActivePotionEffect(Potion.absorption)),
                     NamedCause.of(DamageEntityEvent.CREATOR, entityLivingBase)))
             .type(DamageModifierTypes.ABSORPTION)
             .build();
     return Optional.of(new Tuple<>(modifier, function));
   }
   return Optional.empty();
 }
示例#2
0
 public void applyAttributesModifiersToEntity(
     EntityLivingBase p_111185_1_, BaseAttributeMap p_111185_2_, int p_111185_3_) {
   p_111185_1_.setAbsorptionAmount(
       p_111185_1_.getAbsorptionAmount() + (float) (4 * (p_111185_3_ + 1)));
   super.applyAttributesModifiersToEntity(p_111185_1_, p_111185_2_, p_111185_3_);
 }
示例#3
0
 public void removeAttributesModifiersFromEntity(
     EntityLivingBase p_111187_1_, BaseAttributeMap p_111187_2_, int p_111187_3_) {
   p_111187_1_.setAbsorptionAmount(
       p_111187_1_.getAbsorptionAmount() - (float) (4 * (p_111187_3_ + 1)));
   super.removeAttributesModifiersFromEntity(p_111187_1_, p_111187_2_, p_111187_3_);
 }