diff --git a/Plugin/src/main/java/cz/neumimto/rpg/listeners/BasicListener.java b/Plugin/src/main/java/cz/neumimto/rpg/listeners/BasicListener.java index 76eec1401..e693f22a2 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/listeners/BasicListener.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/listeners/BasicListener.java @@ -286,8 +286,9 @@ public void onIndirectEntityDamage(DamageEntityEvent event, IEntity target = entityService.get(event.getTargetEntity()); ProjectileProperties projectileProperties = ProjectileProperties.cache.get(projectile); if (projectileProperties != null) { + event.setCancelled(true); ProjectileProperties.cache.remove(projectile); - projectileProperties.consumer.accept(shooter, target); + projectileProperties.consumer.accept(event, shooter, target); return; } @@ -326,7 +327,7 @@ public void onSkillDamage(DamageEntityEvent event, } } IEntity targetchar = entityService.get(event.getTargetEntity()); - double finalDamage = event.getBaseDamage() * damageService.getEntityBonusDamage(caster, type); + double finalDamage = event.getOriginalDamage() * damageService.getEntityBonusDamage(caster, type); try (CauseStackManager.StackFrame frame = causeStackManager.pushCauseFrame()) { diff --git a/Plugin/src/main/java/cz/neumimto/rpg/skills/ProjectileProperties.java b/Plugin/src/main/java/cz/neumimto/rpg/skills/ProjectileProperties.java index fd4894d5b..e46c76d29 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/skills/ProjectileProperties.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/skills/ProjectileProperties.java @@ -19,11 +19,12 @@ package cz.neumimto.rpg.skills; import cz.neumimto.rpg.IEntity; +import cz.neumimto.rpg.utils.TriConsumer; import org.spongepowered.api.entity.projectile.Projectile; +import org.spongepowered.api.event.entity.DamageEntityEvent; import java.util.Map; import java.util.WeakHashMap; -import java.util.function.BiConsumer; /** * Created by NeumimTo on 15.1.2015. @@ -37,7 +38,7 @@ protected boolean removeEldestEntry(Map.Entry entry) };*/ public static Map cache = new WeakHashMap<>(); - public BiConsumer consumer; + public TriConsumer consumer; //protected Projectile t; private double damage; // private long lifetime; @@ -50,12 +51,12 @@ public ProjectileProperties(Projectile t, IEntity caster) { this.caster = caster; } - public void onHit(BiConsumer consumer) { + public void onHit(TriConsumer consumer) { this.consumer = consumer; } - public void process(IEntity target) { - consumer.accept(caster, target); + public void process(DamageEntityEvent event, IEntity target) { + consumer.accept(event, caster, target); } public double getDamage() { diff --git a/Plugin/src/main/java/cz/neumimto/rpg/skills/SkillShot.java b/Plugin/src/main/java/cz/neumimto/rpg/skills/SkillShot.java index 9da17158f..340efbc8d 100644 --- a/Plugin/src/main/java/cz/neumimto/rpg/skills/SkillShot.java +++ b/Plugin/src/main/java/cz/neumimto/rpg/skills/SkillShot.java @@ -21,11 +21,12 @@ import cz.neumimto.core.ioc.Inject; import cz.neumimto.rpg.IEntity; import cz.neumimto.rpg.players.IActiveCharacter; +import cz.neumimto.rpg.utils.TriConsumer; import org.spongepowered.api.Game; import org.spongepowered.api.entity.projectile.Projectile; +import org.spongepowered.api.event.entity.DamageEntityEvent; import java.util.Optional; -import java.util.function.BiConsumer; /** * Created by NeumimTo on 12.3.2015. @@ -51,6 +52,6 @@ public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, Skil protected abstract Class getProjectile(IActiveCharacter character, ExtendedSkillInfo info); - protected abstract BiConsumer getHitConsumer(); + protected abstract TriConsumer getHitConsumer(); } diff --git a/Plugin/src/main/java/cz/neumimto/rpg/utils/TriConsumer.java b/Plugin/src/main/java/cz/neumimto/rpg/utils/TriConsumer.java new file mode 100644 index 000000000..700c2e630 --- /dev/null +++ b/Plugin/src/main/java/cz/neumimto/rpg/utils/TriConsumer.java @@ -0,0 +1,11 @@ +package cz.neumimto.rpg.utils; + +/** + * Created by NeumimTo on 29.4.2018. + */ +@FunctionalInterface +public interface TriConsumer { + + void accept(K k, V v, S s); + +} diff --git a/Skills/src/main/java/cz/neumimto/skills/active/IceBolt.java b/Skills/src/main/java/cz/neumimto/skills/active/IceBolt.java index 2db00fcdc..e36ca7721 100644 --- a/Skills/src/main/java/cz/neumimto/skills/active/IceBolt.java +++ b/Skills/src/main/java/cz/neumimto/skills/active/IceBolt.java @@ -77,7 +77,7 @@ public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, Skil int slowamplf = getIntNodeValue(info, SkillNodes.AMPFLIER); - projectileProperties.onHit((caster, target) -> { + projectileProperties.onHit((event, caster, target) -> { target.getEntity().damage(projectileProperties.getDamage(), build.build()); effectService.addEffect(new SlowPotion(caster, slowduration, slowamplf), caster, this); }); diff --git a/Skills/src/main/java/cz/neumimto/skills/active/SkillFireball.java b/Skills/src/main/java/cz/neumimto/skills/active/SkillFireball.java index a58e04812..e777f17de 100644 --- a/Skills/src/main/java/cz/neumimto/skills/active/SkillFireball.java +++ b/Skills/src/main/java/cz/neumimto/skills/active/SkillFireball.java @@ -1,12 +1,22 @@ package cz.neumimto.skills.active; +import static com.flowpowered.math.TrigMath.cos; +import static com.flowpowered.math.TrigMath.sin; + import com.flowpowered.math.imaginary.Quaterniond; import com.flowpowered.math.vector.Vector3d; import cz.neumimto.SkillLocalization; import cz.neumimto.rpg.ResourceLoader; import cz.neumimto.rpg.damage.SkillDamageSourceBuilder; import cz.neumimto.rpg.players.IActiveCharacter; -import cz.neumimto.rpg.skills.*; +import cz.neumimto.rpg.skills.ActiveSkill; +import cz.neumimto.rpg.skills.ExtendedSkillInfo; +import cz.neumimto.rpg.skills.ProjectileProperties; +import cz.neumimto.rpg.skills.SkillModifier; +import cz.neumimto.rpg.skills.SkillNodes; +import cz.neumimto.rpg.skills.SkillResult; +import cz.neumimto.rpg.skills.SkillSettings; +import cz.neumimto.rpg.skills.SkillType; import org.spongepowered.api.data.key.Keys; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.EntityTypes; @@ -15,9 +25,6 @@ import org.spongepowered.api.event.cause.entity.damage.DamageTypes; import org.spongepowered.api.world.World; -import static com.flowpowered.math.TrigMath.cos; -import static com.flowpowered.math.TrigMath.sin; - /** * Created by NeumimTo on 23.12.2015. */ @@ -58,7 +65,7 @@ public SkillResult cast(IActiveCharacter character, ExtendedSkillInfo info, Skil build.fromSkill(this); build.setCaster(character); build.type(getDamageType()); - projectileProperties.onHit((caster, target) -> { + projectileProperties.onHit((event, caster, target) -> { target.getEntity().damage(projectileProperties.getDamage(), build.build()); }); return SkillResult.OK;