Files
Wizardry/src/main/java/electroblob/wizardry/spell/FlamingWeapon.java
T
Electroblob77 8ae6bc9102 Tidy up entity geometry stuff:
- Add a getCentre method for entities to GeometryUtils
- Replace getPositionEyes(0) with getPositionEyes(1) since it's more efficient, and by definition they must be the same
- Remove all the silly getEntityBoundingBox().minY stuff, this bug has been fixed since 1.8! (which begs the question: if it was considered a bug, how on earth did it go unfixed for that long?)
- A few other small things
2020-07-04 13:34:11 +01:00

65 lines
2.5 KiB
Java

package electroblob.wizardry.spell;
import electroblob.wizardry.constants.Constants;
import electroblob.wizardry.data.WizardData;
import electroblob.wizardry.item.SpellActions;
import electroblob.wizardry.registry.WizardryEnchantments;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.util.InventoryUtils;
import electroblob.wizardry.util.ParticleBuilder;
import electroblob.wizardry.util.ParticleBuilder.Type;
import electroblob.wizardry.util.SpellModifiers;
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumHand;
import net.minecraft.world.World;
public class FlamingWeapon extends Spell {
public FlamingWeapon(){
super("flaming_weapon", SpellActions.IMBUE, false);
addProperties(EFFECT_DURATION);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Won't work if the weapon already has the enchantment
if(WizardData.get(caster) != null
&& WizardData.get(caster).getImbuementDuration(WizardryEnchantments.flaming_weapon) <= 0){
for(ItemStack stack : InventoryUtils.getPrioritisedHotbarAndOffhand(caster)){
if((ImbueWeapon.isSword(stack) || ImbueWeapon.isBow(stack))
&& !EnchantmentHelper.getEnchantments(stack).containsKey(WizardryEnchantments.flaming_weapon)){
// The enchantment level as determined by the damage multiplier. The + 0.5f is so that
// weird float processing doesn't incorrectly round it down.
stack.addEnchantment(WizardryEnchantments.flaming_weapon,
modifiers.get(SpellModifiers.POTENCY) == 1.0f ? 1
: (int)((modifiers.get(SpellModifiers.POTENCY) - 1.0f)
/ Constants.POTENCY_INCREASE_PER_TIER + 0.5f));
WizardData.get(caster).setImbuementDuration(WizardryEnchantments.flaming_weapon,
(int)(getProperty(EFFECT_DURATION).floatValue() * modifiers.get(WizardryItems.duration_upgrade)));
if(world.isRemote){
for(int i=0; i<10; i++){
double x = caster.posX + world.rand.nextDouble() * 2 - 1;
double y = caster.posY + caster.getEyeHeight() - 0.5 + world.rand.nextDouble();
double z = caster.posZ + world.rand.nextDouble() * 2 - 1;
ParticleBuilder.create(Type.SPARKLE).pos(x, y, z).vel(0, 0.1, 0).clr(0.9f, 0.7f, 1).spawn(world);
}
}
this.playSound(world, caster, ticksInUse, -1, modifiers);
return true;
}
}
}
return false;
}
}