Skip to content

Commit

Permalink
✨potionEffect() in Potion.java
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusSlover committed May 28, 2024
1 parent e7c94c6 commit 7b35a45
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/main/java/com/marcusslover/plus/lib/potion/Potion.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,23 @@ public class Potion implements IApplicable<LivingEntity, Potion> {
return new Potion(type, durationTicks, amplifier, particles, transparent, icon, force);
}

@Override
public @NotNull Potion apply(@NotNull LivingEntity entity) {
PotionEffect potionEffect = new PotionEffect(this.type, this.duration, this.amplifier)
/**
* Converts this potion to a {@link PotionEffect}.
* @return the potion effect
*/
public @NotNull PotionEffect potionEffect() {
return new PotionEffect(this.type, this.duration, this.amplifier)
.withParticles(this.particles)
.withAmbient(this.transparent)
.withIcon(this.icon);
}

@Override
public @NotNull Potion apply(@NotNull LivingEntity entity) {
PotionEffect potionEffect = this.potionEffect();

//noinspection deprecation
entity.addPotionEffect(potionEffect, this.force);

return this;
}
}

0 comments on commit 7b35a45

Please sign in to comment.