diff --git a/src/main/java/electroblob/wizardry/registry/Spells.java b/src/main/java/electroblob/wizardry/registry/Spells.java index 79b5ab84..090ddaa8 100644 --- a/src/main/java/electroblob/wizardry/registry/Spells.java +++ b/src/main/java/electroblob/wizardry/registry/Spells.java @@ -244,6 +244,7 @@ public final class Spells { public static final Spell stormcloud = placeholder(); + public static final Spell firestorm = placeholder(); public static final Spell zombie_apocalypse = placeholder(); @SubscribeEvent @@ -451,6 +452,7 @@ public final class Spells { registry.register(new Stormcloud()); + registry.register(new Firestorm()); registry.register(new ZombieApocalypse()); } diff --git a/src/main/java/electroblob/wizardry/spell/Firestorm.java b/src/main/java/electroblob/wizardry/spell/Firestorm.java new file mode 100644 index 00000000..19c5ab16 --- /dev/null +++ b/src/main/java/electroblob/wizardry/spell/Firestorm.java @@ -0,0 +1,111 @@ +package electroblob.wizardry.spell; + +import electroblob.wizardry.client.DrawingUtils; +import electroblob.wizardry.item.SpellActions; +import electroblob.wizardry.registry.WizardryItems; +import electroblob.wizardry.util.BlockUtils; +import electroblob.wizardry.util.BlockUtils.SurfaceCriteria; +import electroblob.wizardry.util.EntityUtils; +import electroblob.wizardry.util.ParticleBuilder; +import electroblob.wizardry.util.ParticleBuilder.Type; +import electroblob.wizardry.util.SpellModifiers; +import net.minecraft.entity.EntityLiving; +import net.minecraft.entity.EntityLivingBase; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.Blocks; +import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; +import net.minecraft.util.math.BlockPos; +import net.minecraft.util.math.Vec3d; +import net.minecraft.world.World; + +import javax.annotation.Nullable; + +public class Firestorm extends SpellAreaEffect { + + public Firestorm(){ + super("firestorm", SpellActions.POINT_DOWN, false); + this.soundValues(1.5f, 1.0f, 0); + this.alwaysSucceed(true); + addProperties(BURN_DURATION); + } + + @Override + public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){ + burnNearbyBlocks(world, new Vec3d(caster.posX, caster.getEntityBoundingBox().minY, caster.posZ), caster, modifiers); + return super.cast(world, caster, hand, ticksInUse, modifiers); + } + + @Override + public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){ + burnNearbyBlocks(world, caster.getPositionVector(), caster, modifiers); + return super.cast(world, caster, hand, ticksInUse, target, modifiers); + } + + @Override + public boolean cast(World world, double x, double y, double z, EnumFacing direction, int ticksInUse, int duration, SpellModifiers modifiers){ + burnNearbyBlocks(world, new Vec3d(x, y, z), null, modifiers); + return super.cast(world, x, y, z, direction, ticksInUse, duration, modifiers); + } + + @Override + protected boolean affectEntity(World world, Vec3d origin, @Nullable EntityLivingBase caster, EntityLivingBase target, int targetCount, int ticksInUse, SpellModifiers modifiers){ + target.setFire(getProperty(BURN_DURATION).intValue()); + return true; + } + + @Override + protected void spawnParticleEffect(World world, Vec3d origin, double radius, @Nullable EntityLivingBase caster, SpellModifiers modifiers){ + + for(int i=0; i<100; i++){ + double speed = (world.rand.nextBoolean() ? 1 : -1) * (0.1 + 0.05 * world.rand.nextDouble()); + ParticleBuilder.create(Type.MAGIC_FIRE) + .pos(origin.x, origin.y + world.rand.nextDouble() * 3, origin.z) + .vel(0, 0, 0) + .scale(2) + .time(40 + world.rand.nextInt(10)) + .spin(world.rand.nextDouble() * (radius - 0.5) + 0.5, speed) + .spawn(world); + } + + for(int i=0; i<60; i++){ + double speed = (world.rand.nextBoolean() ? 1 : -1) * (0.05 + 0.02 * world.rand.nextDouble()); + float r = world.rand.nextFloat(); + ParticleBuilder.create(Type.CLOUD) + .pos(origin.x, origin.y + world.rand.nextDouble() * 2.5, origin.z) + .clr(DrawingUtils.mix(DrawingUtils.mix(0xffbe00, 0xff3600, r/0.6f), 0x222222, (r - 0.6f)/0.4f)) + .spin(r * (radius - 1) + 0.5, speed) + .spawn(world); + } + } + + private void burnNearbyBlocks(World world, Vec3d origin, @Nullable EntityLivingBase caster, SpellModifiers modifiers){ + + if(!world.isRemote && EntityUtils.canDamageBlocks(caster, world)){ + + double radius = getProperty(EFFECT_RADIUS).floatValue() * modifiers.get(WizardryItems.blast_upgrade); + + for(int i = -(int)radius; i <= (int)radius; i++){ + for(int j = -(int)radius; j <= (int)radius; j++){ + + BlockPos pos = new BlockPos(origin).add(i, 0, j); + + Integer y = BlockUtils.getNearestSurface(world, new BlockPos(pos), EnumFacing.UP, (int)radius, true, SurfaceCriteria.NOT_AIR_TO_AIR); + + if(y != null){ + + pos = new BlockPos(pos.getX(), y, pos.getZ()); + + double dist = origin.distanceTo(new Vec3d(origin.x + i, y, origin.z + j)); + + // Randomised with weighting so that the nearer the block the more likely it is to be set alight. + if(y != -1 && world.rand.nextInt((int)(dist * 2) + 1) < radius && dist < radius && dist > 1.5){ + world.setBlockState(pos, Blocks.FIRE.getDefaultState()); + } + } + } + } + } + } + +} diff --git a/src/main/java/electroblob/wizardry/util/BlockUtils.java b/src/main/java/electroblob/wizardry/util/BlockUtils.java index 675d5336..538e3637 100644 --- a/src/main/java/electroblob/wizardry/util/BlockUtils.java +++ b/src/main/java/electroblob/wizardry/util/BlockUtils.java @@ -460,7 +460,7 @@ public final class BlockUtils { || world.isSideSolid(pos, side) && world.isAirBlock(pos.offset(side))); /** Surface criterion which defines a surface as the boundary between any non-air block and an air block. - * Used for particles. */ + * Used for particles, and is also good for placing fire. */ // Was getNearestFloorLevelC SurfaceCriteria NOT_AIR_TO_AIR = basedOn(World::isAirBlock).flip(); diff --git a/src/main/resources/assets/ebwizardry/lang/en_gb.lang b/src/main/resources/assets/ebwizardry/lang/en_gb.lang index 8fc1175e..da082373 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_gb.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_gb.lang @@ -785,6 +785,7 @@ spell.ebwizardry\:firebomb=Firebomb spell.ebwizardry\:fire_resistance=Fire Resistance spell.ebwizardry\:fire_sigil=Fire Sigil spell.ebwizardry\:fireskin=Fireskin +spell.ebwizardry\:firestorm=Firestorm spell.ebwizardry\:fire_breath=Fire Breath spell.ebwizardry\:flame_ray=Flame Ray spell.ebwizardry\:flaming_axe=Flaming Axe @@ -962,6 +963,7 @@ spell.ebwizardry\:firebomb.desc=Lanches a firebomb in the direction you are poin spell.ebwizardry\:fire_resistance.desc=Grants the caster fire resistance for 30 seconds. spell.ebwizardry\:fire_sigil.desc=Places a magical fire trap on the ground which damages and sets on fire the creature that triggers it. spell.ebwizardry\:fireskin.desc=Cloaks the caster in flames for 30 seconds, causing anything that attacks them to catch fire. +spell.ebwizardry\:firestorm.desc="Purge the land and purge the soil!\nTrees shall burn and lakes shall boil!\nTorch the wood and scorch the stone!\nAll bow before the fiery throne!" spell.ebwizardry\:fire_breath.desc="I am the dragon." spell.ebwizardry\:flame_ray.desc=Creates a stream of flames in the direction you are pointing which sets on fire and continually damages targets. spell.ebwizardry\:flaming_axe.desc=Creates a flaming axe which sets enemies on fire when hit. Lasts for 30 seconds. diff --git a/src/main/resources/assets/ebwizardry/lang/en_us.lang b/src/main/resources/assets/ebwizardry/lang/en_us.lang index 7b9df5c4..a2fea7e5 100644 --- a/src/main/resources/assets/ebwizardry/lang/en_us.lang +++ b/src/main/resources/assets/ebwizardry/lang/en_us.lang @@ -785,6 +785,7 @@ spell.ebwizardry\:firebomb=Firebomb spell.ebwizardry\:fire_resistance=Fire Resistance spell.ebwizardry\:fire_sigil=Fire Sigil spell.ebwizardry\:fireskin=Fireskin +spell.ebwizardry\:firestorm=Firestorm spell.ebwizardry\:fire_breath=Fire Breath spell.ebwizardry\:flame_ray=Flame Ray spell.ebwizardry\:flaming_axe=Flaming Axe @@ -962,6 +963,7 @@ spell.ebwizardry\:firebomb.desc=Lanches a firebomb in the direction you are poin spell.ebwizardry\:fire_resistance.desc=Grants the caster fire resistance for 30 seconds. spell.ebwizardry\:fire_sigil.desc=Places a magical fire trap on the ground which damages and sets on fire the creature that triggers it. spell.ebwizardry\:fireskin.desc=Cloaks the caster in flames for 30 seconds, causing anything that attacks them to catch fire. +spell.ebwizardry\:firestorm.desc="Purge the land and purge the soil!\nTrees shall burn and lakes shall boil!\nTorch the wood and scorch the stone!\nAll bow before the fiery throne!" spell.ebwizardry\:fire_breath.desc="I am the dragon." spell.ebwizardry\:flame_ray.desc=Creates a stream of flames in the direction you are pointing which sets on fire and continually damages targets. spell.ebwizardry\:flaming_axe.desc=Creates a flaming axe which sets enemies on fire when hit. Lasts for 30 seconds. diff --git a/src/main/resources/assets/ebwizardry/sounds.json b/src/main/resources/assets/ebwizardry/sounds.json index ab443ce2..c7707528 100644 --- a/src/main/resources/assets/ebwizardry/sounds.json +++ b/src/main/resources/assets/ebwizardry/sounds.json @@ -166,6 +166,7 @@ "spell.fire_resistance": {"category": "spells", "sounds": ["ebwizardry:buff"]}, "spell.fire_sigil": {"category": "spells", "sounds": ["fire/ignite"]}, "spell.fireskin": {"category": "spells", "sounds": ["ebwizardry:buff"]}, + "spell.firestorm": {"category": "spells", "sounds": ["ebwizardry:firestorm"]}, "spell.fire_breath.start": {"category": "spells", "sounds": ["ebwizardry:flames_start"]}, "spell.fire_breath.loop": {"category": "spells", "sounds": ["ebwizardry:flames_loop"]}, "spell.fire_breath.end": {"category": "spells", "sounds": ["ebwizardry:flames_end"]}, diff --git a/src/main/resources/assets/ebwizardry/sounds/firestorm.ogg b/src/main/resources/assets/ebwizardry/sounds/firestorm.ogg new file mode 100644 index 00000000..1267892d Binary files /dev/null and b/src/main/resources/assets/ebwizardry/sounds/firestorm.ogg differ diff --git a/src/main/resources/assets/ebwizardry/spells/firestorm.json b/src/main/resources/assets/ebwizardry/spells/firestorm.json new file mode 100644 index 00000000..9461f620 --- /dev/null +++ b/src/main/resources/assets/ebwizardry/spells/firestorm.json @@ -0,0 +1,23 @@ +{ + "enabled": { + "book": true, + "scroll": true, + "wands": true, + "npcs": true, + "dispensers": true, + "commands": true, + "treasure": true, + "trades": true, + "looting": true + }, + "tier": "master", + "element": "fire", + "type": "attack", + "cost": 80, + "chargeup": 20, + "cooldown": 250, + "base_properties": { + "effect_radius": 6, + "burn_duration": 15 + } +} \ No newline at end of file