Add mark sacrifice spell

This commit is contained in:
Electroblob77
2020-07-30 22:54:37 +01:00
parent a321e4ef66
commit 0d7d36c0b5
9 changed files with 106 additions and 1 deletions
@@ -493,7 +493,7 @@ public class ItemArtefact extends Item {
}
@SubscribeEvent
public static void onSpellCastPostEvent(SpellCastEvent.Pre event){
public static void onSpellCastPostEvent(SpellCastEvent.Post event){
if(event.getCaster() instanceof EntityPlayer){
@@ -241,6 +241,7 @@ public final class Spells {
// Wizardry 4.3 spells
public static final Spell blinding_flash = placeholder();
public static final Spell mark_sacrifice = placeholder();
public static final Spell stormcloud = placeholder();
public static final Spell fangs = placeholder();
@@ -452,6 +453,7 @@ public final class Spells {
// Wizardry 4.3 spells
registry.register(new BlindingFlash());
registry.register(new MarkSacrifice());
registry.register(new Stormcloud());
registry.register(new Fangs());
@@ -55,6 +55,7 @@ public final class WizardryPotions {
public static final Potion curse_of_undeath = placeholder();
public static final Potion containment = placeholder();
public static final Potion frost_step = placeholder();
public static final Potion mark_of_sacrifice = placeholder();
/**
* Sets both the registry and unlocalised names of the given potion, then registers it with the given registry. Use
@@ -190,6 +191,9 @@ public final class WizardryPotions {
registerPotion(registry, "frost_step", new PotionFrostStep(false, 0).setBeneficial());
registerPotion(registry, "mark_of_sacrifice", new PotionMagicEffect(true, 0xe90e48,
new ResourceLocation(Wizardry.MODID, "textures/gui/potion_icons/mark_of_sacrifice.png")));
}
}
@@ -0,0 +1,71 @@
package electroblob.wizardry.spell;
import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.registry.WizardryPotions;
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.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.Vec3d;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.living.LivingHurtEvent;
import net.minecraftforge.fml.common.Mod.EventBusSubscriber;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@EventBusSubscriber
public class MarkSacrifice extends SpellRay {
private static final float DAMAGE_INCREASE_PER_LEVEL = 0.6f;
public MarkSacrifice(){
super("mark_sacrifice", SpellActions.POINT, false);
this.soundValues(1, 1.1f, 0.2f);
addProperties(EFFECT_DURATION, EFFECT_STRENGTH);
}
@Override
protected boolean onEntityHit(World world, Entity target, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
if(EntityUtils.isLiving(target)){
((EntityLivingBase)target).addPotionEffect(new PotionEffect(WizardryPotions.mark_of_sacrifice,
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)),
getProperty(EFFECT_STRENGTH).intValue() + SpellBuff.getStandardBonusAmplifier(modifiers.get(SpellModifiers.POTENCY))));
}
return true;
}
@Override
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, Vec3d hit, EntityLivingBase caster, Vec3d origin, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
protected boolean onMiss(World world, EntityLivingBase caster, Vec3d origin, Vec3d direction, int ticksInUse, SpellModifiers modifiers){
return true;
}
@Override
protected void spawnParticle(World world, double x, double y, double z, double vx, double vy, double vz){
ParticleBuilder.create(Type.DARK_MAGIC).pos(x, y, z).clr(0xe90e48).spawn(world);
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).time(12 + world.rand.nextInt(8)).clr(0xff7bbb).spawn(world);
}
@SubscribeEvent
public static void onLivingHurtEvent(LivingHurtEvent event){
PotionEffect effect = event.getEntityLiving().getActivePotionEffect(WizardryPotions.mark_of_sacrifice);
if(effect != null && event.getSource().isMagicDamage()){
event.setAmount(event.getAmount() * (1 + effect.getAmplifier() * DAMAGE_INCREASE_PER_LEVEL));
event.getEntityLiving().removePotionEffect(WizardryPotions.mark_of_sacrifice);
}
}
}