Spell hierarchisation and refactoring, plus miscellaneous renaming and minor refactoring
- Adds new generic spell superclasses which aim to group spells such that duplicate code is eliminated, and functions standardised, as much as possible. - Removes numerous spell classes which are no longer required as a result of this change, and replaces them with instances of the relevant generic spell classes. - Changes the remaining spell classes to fit with the new system, mostly by having them extend the generic spell classes. - Completes the transfer of particle spawning to the ParticleBuilder system.
This commit is contained in:
@@ -4,58 +4,38 @@ import electroblob.wizardry.constants.Element;
|
||||
import electroblob.wizardry.constants.SpellType;
|
||||
import electroblob.wizardry.constants.Tier;
|
||||
import electroblob.wizardry.entity.construct.EntityArrowRain;
|
||||
import electroblob.wizardry.registry.WizardryItems;
|
||||
import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.SpellModifiers;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.EnumAction;
|
||||
import net.minecraft.util.EnumHand;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class ArrowRain extends Spell {
|
||||
public class ArrowRain extends SpellConstructRanged<EntityArrowRain> {
|
||||
|
||||
public ArrowRain(){
|
||||
super(Tier.MASTER, 75, Element.SORCERY, "arrow_rain", SpellType.ATTACK, 300, EnumAction.NONE, false);
|
||||
super("arrow_rain", Tier.MASTER, Element.SORCERY, SpellType.ATTACK, 75, 300, EntityArrowRain::new, 120, 20, WizardrySounds.SPELL_SUMMONING);
|
||||
this.floor(true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean doesSpellRequirePacket(){
|
||||
return false;
|
||||
protected boolean spawnConstruct(World world, double x, double y, double z, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
|
||||
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the position.
|
||||
// 3 is the distance to move the entity back towards the caster.
|
||||
double dx = caster.posX - x;
|
||||
double dz = caster.posZ - z;
|
||||
double distRatio = 3 / Math.sqrt(dx * dx + dz * dz);
|
||||
x += dx * distRatio;
|
||||
z += dz * distRatio;
|
||||
// Moves the entity up 5 blocks so that it is above mobs' heads.
|
||||
y += 5;
|
||||
|
||||
return super.spawnConstruct(world, x, y, z, caster, modifiers);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
|
||||
|
||||
RayTraceResult rayTrace = WizardryUtilities.rayTrace(20 * modifiers.get(WizardryItems.range_upgrade), world,
|
||||
caster, false);
|
||||
|
||||
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
|
||||
if(!world.isRemote){
|
||||
double x = rayTrace.hitVec.x;
|
||||
double y = rayTrace.hitVec.y;
|
||||
double z = rayTrace.hitVec.z;
|
||||
// Moves the entity back towards the caster a bit, so the area of effect is better centred on the
|
||||
// position.
|
||||
// 3.0d is the distance to move the entity back towards the caster.
|
||||
double dx = caster.posX - x;
|
||||
double dz = caster.posZ - z;
|
||||
double distRatio = 3.0d / Math.sqrt(dx * dx + dz * dz);
|
||||
x += dx * distRatio;
|
||||
z += dz * distRatio;
|
||||
|
||||
EntityArrowRain arrowrain = new EntityArrowRain(world, x, y + 5, z, caster,
|
||||
(int)(120 * modifiers.get(WizardryItems.duration_upgrade)),
|
||||
modifiers.get(SpellModifiers.DAMAGE));
|
||||
arrowrain.rotationYaw = caster.rotationYawHead;
|
||||
world.spawnEntity(arrowrain);
|
||||
}
|
||||
caster.swingArm(hand);
|
||||
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 1.0F, 1.0F);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
protected void addConstructExtras(EntityArrowRain construct, EntityLivingBase caster, SpellModifiers modifiers){
|
||||
// Makes the arrows shoot in the direction the caster was looking when they cast the spell.
|
||||
construct.rotationYaw = caster.rotationYawHead;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user