package electroblob.wizardry.entity.construct; import java.util.List; import electroblob.wizardry.registry.WizardryPotions; import electroblob.wizardry.registry.WizardrySounds; import electroblob.wizardry.util.MagicDamage; import electroblob.wizardry.util.MagicDamage.DamageType; import electroblob.wizardry.util.ParticleBuilder; import electroblob.wizardry.util.ParticleBuilder.Type; import electroblob.wizardry.util.WizardryUtilities; import net.minecraft.entity.EntityLivingBase; import net.minecraft.potion.PotionEffect; import net.minecraft.util.DamageSource; import net.minecraft.world.World; public class EntityBlizzard extends EntityMagicConstruct { public EntityBlizzard(World world){ super(world); this.height = 1.0f; this.width = 1.0f; } public void onUpdate(){ if(this.ticksExisted % 120 == 1){ this.playSound(WizardrySounds.SPELL_LOOP_WIND, 1.0f, 1.0f); } super.onUpdate(); if(!this.world.isRemote){ List targets = WizardryUtilities.getEntitiesWithinRadius(3.0d, this.posX, this.posY, this.posZ, this.world); for(EntityLivingBase target : targets){ if(this.isValidTarget(target)){ if(this.getCaster() != null){ WizardryUtilities.attackEntityWithoutKnockback(target, MagicDamage.causeIndirectMagicDamage(this, getCaster(), DamageType.FROST), 1 * damageMultiplier); }else{ WizardryUtilities.attackEntityWithoutKnockback(target, DamageSource.MAGIC, 1 * damageMultiplier); } } // All entities are slowed, even the caster (except those immune to frost effects) if(!MagicDamage.isEntityImmune(DamageType.FROST, target)) target.addPotionEffect(new PotionEffect(WizardryPotions.frost, 20, 0)); } }else{ for(int i=1; i<12; i++){ double speed = (rand.nextBoolean() ? 1 : -1) * 0.1 + 0.05 * rand.nextDouble(); ParticleBuilder.create(Type.SNOW).pos(this.posX, this.posY + rand.nextDouble() * 3, this.posZ).vel(0, 0, 0) .time(100).scale(2).spin(rand.nextDouble() * 2.5 + 0.5, speed).spawn(world); } } } }