Skip to content

Commit

Permalink
Merge pull request #821 from Chronoken/main
Browse files Browse the repository at this point in the history
Fix caster targeting
  • Loading branch information
Chronoken authored Dec 15, 2023
2 parents 4aeb4b9 + 0755354 commit c12ed67
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void run() {
radius = Math.min(radius, MagicSpells.getGlobalRadius());

for (Entity entity : caster.getNearbyEntities(radius, radius, radius)) {
if (!(entity instanceof LivingEntity target) || !validTargetList.canTarget(target)) continue;
if (!(entity instanceof LivingEntity target) || !validTargetList.canTarget(caster, target)) continue;

if (data.checkPlugins) {
MagicSpellsEntityDamageByEntityEvent event = new MagicSpellsEntityDamageByEntityEvent(caster, target, DamageCause.ENTITY_ATTACK, 1, FlamewalkSpell.this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,11 +417,11 @@ else if (e.getDamager() instanceof Projectile projectile) {
}

if (damager instanceof Player pl) {
// Check if player's damaged target is his minion, if its not, make him attack your target
// Check if player's damaged target is his minion, if it's not, make him attack your target
if (!isActive(pl)) return;
for (BuffSpell buff : MagicSpells.getBuffManager().getActiveBuffs(pl)) {
if (!(buff instanceof MinionSpell)) continue;
if (entity.equals(((MinionSpell)buff).minions.get(pl.getUniqueId()))) {
if (!(buff instanceof MinionSpell minionBuff)) continue;
if (entity.equals(minionBuff.minions.get(pl.getUniqueId()))) {
e.setCancelled(true);
return;
}
Expand All @@ -433,7 +433,7 @@ else if (e.getDamager() instanceof Projectile projectile) {
}

// Check if the entity can be targeted by the minion
if (!minionTargetList.canTarget(entity)) return;
if (!minionTargetList.canTarget(pl, entity)) return;

targets.put(pl.getUniqueId(),entity);
MobUtil.setTarget(minions.get(pl.getUniqueId()), entity);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,8 +263,8 @@ public CastResult castAtEntityFromLocation(SpellData data) {

//check entities in the beam range
for (LivingEntity e : loc.getNearbyLivingEntities(hitRadius, verticalHitRadius)) {
if (e == data.caster() || !e.isValid() || immune.contains(e)) continue;
if (validTargetList != null && !validTargetList.canTarget(e)) continue;
if (!e.isValid() || immune.contains(e)) continue;
if (validTargetList != null && !validTargetList.canTarget(data.caster(), e)) continue;

SpellTargetEvent event = new SpellTargetEvent(this, locData, e);
if (!event.callEvent()) continue;
Expand All @@ -278,7 +278,6 @@ public CastResult castAtEntityFromLocation(SpellData data) {
playSpellEffects(EffectPosition.TARGET, entity, subData);
playSpellEffectsTrail(data.caster().getLocation(), entity.getLocation(), subData);
immune.add(e);

if (stopOnHitEntity) break mainLoop;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ public CastResult castAtEntityFromLocation(SpellData data) {

//check entities in the beam range
for (LivingEntity e : loc.getNearbyLivingEntities(hitRadius, verticalHitRadius)) {
if (e == data.caster() || !e.isValid() || immune.contains(e)) continue;
if (validTargetList != null && !validTargetList.canTarget(e)) continue;
if (!e.isValid() || immune.contains(e)) continue;
if (validTargetList != null && !validTargetList.canTarget(data.caster(), e)) continue;

SpellTargetEvent event = new SpellTargetEvent(this, locData, e);
if (!event.callEvent()) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public void onExplosionPrime(ExplosionPrimeEvent event) {
List<Entity> inRange = fireball.getNearbyEntities(noExplosionDamageRange, noExplosionDamageRange, noExplosionDamageRange);
for (Entity entity : inRange) {
if (!(entity instanceof LivingEntity target)) continue;
if (!validTargetList.canTarget(entity)) continue;
if (!validTargetList.canTarget(caster, entity)) continue;

double noExplosionDamage = this.noExplosionDamage.get(data);
if (powerAffectsNoExplosionDamage.get(data)) noExplosionDamage *= data.power();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,11 +317,8 @@ public void run() {
box.setCenter(loc);

for (LivingEntity e : data.caster().getWorld().getLivingEntities()) {
if (e.equals(data.caster())) continue;
if (!e.isValid()) continue;
if (immune.contains(e)) continue;
if (!box.contains(e)) continue;
if (entityTargetList != null && !entityTargetList.canTarget(e)) continue;
if (!e.isValid() || immune.contains(e) || !box.contains(e)) continue;
if (entityTargetList != null && !entityTargetList.canTarget(data.caster(), e)) continue;

SpellTargetEvent event = new SpellTargetEvent(OrbitSpell.this, data, e);
if (!event.callEvent()) continue;
Expand Down

0 comments on commit c12ed67

Please sign in to comment.