From 6cd6411c25ff4da88a0be773e9010b19a8f5ce06 Mon Sep 17 00:00:00 2001 From: Electroblob77 <35599699+Electroblob77@users.noreply.github.com> Date: Sat, 25 Jan 2020 22:50:45 +0000 Subject: [PATCH] Use target lifetime rather than construct lifetime when dealing periodic damage; means targets don't all get damaged at once --- .../entity/construct/EntityBubble.java | 2 +- .../entity/construct/EntityHammer.java | 48 +++++++++---------- .../entity/construct/EntityHealAura.java | 2 +- 3 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java b/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java index e494c610..08a59b14 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityBubble.java @@ -65,7 +65,7 @@ public class EntityBubble extends EntityMagicConstruct { if(isDarkOrb){ if(WizardryUtilities.getRider(this) != null - && this.ticksExisted % Spells.entrapment.getProperty(Entrapment.DAMAGE_INTERVAL).intValue() == 0){ + && WizardryUtilities.getRider(this).ticksExisted % Spells.entrapment.getProperty(Entrapment.DAMAGE_INTERVAL).intValue() == 0){ if(this.getCaster() != null){ WizardryUtilities.getRider(this).attackEntityFrom( MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.MAGIC), diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java index 8a56a293..8aa12a20 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHammer.java @@ -80,8 +80,8 @@ public class EntityHammer extends EntityMagicConstruct { if(this.world.isRemote && this.ticksExisted % 3 == 0){ ParticleBuilder.create(Type.SPARK) - .pos(this.posX - 0.5d + rand.nextDouble(), this.posY + 2 * rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble()) - .spawn(world); + .pos(this.posX - 0.5d + rand.nextDouble(), this.posY + 2 * rand.nextDouble(), this.posZ - 0.5d + rand.nextDouble()) + .spawn(world); } this.prevPosX = this.posX; @@ -103,39 +103,37 @@ public class EntityHammer extends EntityMagicConstruct { this.rotationPitch = 0; this.spin = false; - if(this.ticksExisted % Spells.lightning_hammer.getProperty(LightningHammer.ATTACK_INTERVAL).floatValue() == 0){ + double seekerRange = Spells.lightning_hammer.getProperty(Spell.EFFECT_RADIUS).doubleValue(); - double seekerRange = Spells.lightning_hammer.getProperty(Spell.EFFECT_RADIUS).doubleValue(); + List targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, + this.posY + 1, this.posZ, world); - List targets = WizardryUtilities.getEntitiesWithinRadius(seekerRange, this.posX, - this.posY + 1, this.posZ, world); + int maxTargets = Spells.lightning_hammer.getProperty(LightningHammer.SECONDARY_MAX_TARGETS).intValue(); + while(targets.size() > maxTargets) targets.remove(targets.size() - 1); - int maxTargets = Spells.lightning_hammer.getProperty(LightningHammer.SECONDARY_MAX_TARGETS).intValue(); - while(targets.size() > maxTargets) targets.remove(targets.size() - 1); + for(EntityLivingBase target : targets){ - for(EntityLivingBase target : targets){ + if(WizardryUtilities.isLiving(target) && this.isValidTarget(target) + && target.ticksExisted % Spells.lightning_hammer.getProperty(LightningHammer.ATTACK_INTERVAL).floatValue() == 0){ - if(WizardryUtilities.isLiving(target) && this.isValidTarget(target)){ + if(world.isRemote){ - if(world.isRemote){ + ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world); - ParticleBuilder.create(Type.LIGHTNING).pos(posX, posY + height - 0.1, posZ) .target(target).spawn(world); + ParticleBuilder.spawnShockParticles(world, target.posX, + target.getEntityBoundingBox().minY + target.height, target.posZ); + } - ParticleBuilder.spawnShockParticles(world, target.posX, - target.getEntityBoundingBox().minY + target.height, target.posZ); - } + target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); - target.playSound(WizardrySounds.ENTITY_HAMMER_ATTACK, 1.0F, rand.nextFloat() * 0.4F + 1.5F); + float damage = Spells.lightning_hammer.getProperty(Spell.SPLASH_DAMAGE).floatValue() * damageMultiplier; - float damage = Spells.lightning_hammer.getProperty(Spell.SPLASH_DAMAGE).floatValue() * damageMultiplier; - - if(this.getCaster() != null){ - WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage( - this, getCaster(), DamageType.SHOCK), damage); - WizardryUtilities.applyStandardKnockback(this, target); - }else{ - target.attackEntityFrom(DamageSource.MAGIC, damage); - } + if(this.getCaster() != null){ + WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage( + this, getCaster(), DamageType.SHOCK), damage); + WizardryUtilities.applyStandardKnockback(this, target); + }else{ + target.attackEntityFrom(DamageSource.MAGIC, damage); } } } diff --git a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java index df3dd462..dc32d17b 100644 --- a/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java +++ b/src/main/java/electroblob/wizardry/entity/construct/EntityHealAura.java @@ -62,7 +62,7 @@ public class EntityHealAura extends EntityMagicConstruct { target.motionZ = velZ; } - }else if(target.getHealth() < target.getMaxHealth() && this.ticksExisted % 5 == 0){ + }else if(target.getHealth() < target.getMaxHealth() && target.ticksExisted % 5 == 0){ target.heal(Spells.healing_aura.getProperty(Spell.HEALTH).floatValue() * damageMultiplier); } }