-
Notifications
You must be signed in to change notification settings - Fork 68
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
170 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
148 changes: 148 additions & 0 deletions
148
src/main/java/io/redspace/ironsspellbooks/spells/fire/FlamingStrikeSpell.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
package io.redspace.ironsspellbooks.spells.fire; | ||
|
||
import io.redspace.ironsspellbooks.IronsSpellbooks; | ||
import io.redspace.ironsspellbooks.api.config.DefaultConfig; | ||
import io.redspace.ironsspellbooks.api.magic.MagicData; | ||
import io.redspace.ironsspellbooks.api.registry.SchoolRegistry; | ||
import io.redspace.ironsspellbooks.api.spells.*; | ||
import io.redspace.ironsspellbooks.api.util.AnimationHolder; | ||
import io.redspace.ironsspellbooks.api.util.CameraShakeData; | ||
import io.redspace.ironsspellbooks.api.util.CameraShakeManager; | ||
import io.redspace.ironsspellbooks.api.util.Utils; | ||
import io.redspace.ironsspellbooks.capabilities.magic.MagicManager; | ||
import io.redspace.ironsspellbooks.damage.DamageSources; | ||
import io.redspace.ironsspellbooks.damage.ISpellDamageSource; | ||
import io.redspace.ironsspellbooks.entity.spells.flame_strike.FlameStrike; | ||
import io.redspace.ironsspellbooks.particle.ShockwaveParticleOptions; | ||
import io.redspace.ironsspellbooks.registries.SoundRegistry; | ||
import io.redspace.ironsspellbooks.util.ParticleHelper; | ||
import net.minecraft.core.particles.ParticleTypes; | ||
import net.minecraft.network.chat.Component; | ||
import net.minecraft.network.chat.MutableComponent; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.sounds.SoundEvent; | ||
import net.minecraft.world.damagesource.DamageSource; | ||
import net.minecraft.world.entity.Entity; | ||
import net.minecraft.world.entity.LivingEntity; | ||
import net.minecraft.world.entity.MobType; | ||
import net.minecraft.world.entity.player.Player; | ||
import net.minecraft.world.level.Level; | ||
import net.minecraft.world.phys.AABB; | ||
import net.minecraft.world.phys.Vec3; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
@AutoSpellConfig | ||
public class FlamingStrikeSpell extends AbstractSpell { | ||
private final ResourceLocation spellId = new ResourceLocation(IronsSpellbooks.MODID, "flaming_strike"); | ||
|
||
@Override | ||
public List<MutableComponent> getUniqueInfo(int spellLevel, LivingEntity caster) { | ||
return List.of(Component.translatable("ui.irons_spellbooks.damage", getDamageText(spellLevel, caster))); | ||
} | ||
|
||
private final DefaultConfig defaultConfig = new DefaultConfig() | ||
.setMinRarity(SpellRarity.COMMON) | ||
.setSchoolResource(SchoolRegistry.HOLY_RESOURCE) | ||
.setMaxLevel(5) | ||
.setCooldownSeconds(15) | ||
.build(); | ||
|
||
public FlamingStrikeSpell() { | ||
this.manaCostPerLevel = 15; | ||
this.baseSpellPower = 5; | ||
this.spellPowerPerLevel = 3; | ||
this.castTime = 16; | ||
this.baseManaCost = 30; | ||
} | ||
|
||
@Override | ||
public boolean canBeInterrupted(Player player) { | ||
return false; | ||
} | ||
|
||
@Override | ||
public int getEffectiveCastTime(int spellLevel, @Nullable LivingEntity entity) { | ||
//due to melee animation timing, we do not want cast time attribute to affect this spell | ||
return getCastTime(spellLevel); | ||
} | ||
|
||
@Override | ||
public CastType getCastType() { | ||
return CastType.LONG; | ||
} | ||
|
||
@Override | ||
public DefaultConfig getDefaultConfig() { | ||
return defaultConfig; | ||
} | ||
|
||
@Override | ||
public ResourceLocation getSpellResource() { | ||
return spellId; | ||
} | ||
|
||
@Override | ||
public Optional<SoundEvent> getCastStartSound() { | ||
return Optional.of(SoundRegistry.DIVINE_SMITE_WINDUP.get()); | ||
} | ||
|
||
@Override | ||
public Optional<SoundEvent> getCastFinishSound() { | ||
return Optional.of(SoundRegistry.DIVINE_SMITE_CAST.get()); | ||
} | ||
|
||
@Override | ||
public void onCast(Level level, int spellLevel, LivingEntity entity, MagicData playerMagicData) { | ||
float radius = 2.5f; | ||
Vec3 hitLocation = entity.position().add(0, entity.getBbHeight() * .4f, 0).add(entity.getForward().multiply(1.45f, 0, 1.45f)); | ||
var entities = level.getEntities(entity, AABB.ofSize(hitLocation, radius * 2, radius, radius * 2)); | ||
for (Entity targetEntity : entities) { | ||
if (entity.distanceTo(targetEntity) < radius && Utils.hasLineOfSight(level, hitLocation, targetEntity.getBoundingBox().getCenter(), true)) { | ||
if (DamageSources.applyDamage(targetEntity, getDamage(spellLevel, entity), this.getDamageSource(entity))) { | ||
MagicManager.spawnParticles(level, ParticleHelper.EMBERS, targetEntity.getX(), targetEntity.getY() + targetEntity.getBbHeight() * .5f, targetEntity.getZ(), 50, targetEntity.getBbWidth() * .5f, targetEntity.getBbHeight() * .5f, targetEntity.getBbWidth() * .5f, .03, false); | ||
} | ||
} | ||
} | ||
FlameStrike flameStrike = new FlameStrike(level); | ||
flameStrike.moveTo(hitLocation); | ||
flameStrike.setYRot(entity.getYRot()); | ||
level.addFreshEntity(flameStrike); | ||
super.onCast(level, spellLevel, entity, playerMagicData); | ||
} | ||
|
||
@Override | ||
public DamageSource getDamageSource(@Nullable Entity projectile, Entity attacker) { | ||
return ((ISpellDamageSource) super.getDamageSource(projectile, attacker)).setFireTime(3).get(); | ||
} | ||
|
||
private float getDamage(int spellLevel, LivingEntity entity) { | ||
return getSpellPower(spellLevel, entity) + Utils.getWeaponDamage(entity, MobType.UNDEFINED); | ||
} | ||
|
||
|
||
private String getDamageText(int spellLevel, LivingEntity entity) { | ||
if (entity != null) { | ||
float weaponDamage = Utils.getWeaponDamage(entity, MobType.UNDEFINED); | ||
String plus = ""; | ||
if (weaponDamage > 0) { | ||
plus = String.format(" (+%s)", Utils.stringTruncation(weaponDamage, 1)); | ||
} | ||
String damage = Utils.stringTruncation(getDamage(spellLevel, entity), 1); | ||
return damage + plus; | ||
} | ||
return "" + getSpellPower(spellLevel, entity); | ||
} | ||
|
||
@Override | ||
public AnimationHolder getCastStartAnimation() { | ||
return SpellAnimations.OVERHEAD_MELEE_SWING_ANIMATION; | ||
} | ||
|
||
@Override | ||
public AnimationHolder getCastFinishAnimation() { | ||
return AnimationHolder.pass(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters