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:
Electroblob
2018-06-20 22:25:54 +01:00
parent b6400c72a7
commit 29261082f1
222 changed files with 4412 additions and 9016 deletions
@@ -4,60 +4,31 @@ import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.entity.construct.EntityHammer;
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.entity.EntityLivingBase;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class LightningHammer extends Spell {
public class LightningHammer extends SpellConstructRanged<EntityHammer> {
public LightningHammer(){
super(Tier.MASTER, 100, Element.LIGHTNING, "lightning_hammer", SpellType.ATTACK, 300, EnumAction.BOW, false);
super("lightning_hammer", Tier.MASTER, Element.LIGHTNING, SpellType.ATTACK, 100, 300, EntityHammer::new, 600, 40, WizardrySounds.SPELL_SUMMONING);
this.soundValues(3, 1, 0);
this.floor(true);
this.overlap(true);
}
@Override
public boolean doesSpellRequirePacket(){
return false;
protected boolean spawnConstruct(World world, double x, double y, double z, EntityLivingBase caster, SpellModifiers modifiers){
// TESTME: Does this need to be one block higher?
if(!world.canBlockSeeSky(new BlockPos(x, y, z))) return false;
return super.spawnConstruct(world, x, y + 50, z, caster, modifiers);
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(40 * modifiers.get(WizardryItems.range_upgrade), world,
caster, false);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Not sure why it is +1 but it has to be to work properly.
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityHammer hammer = new EntityHammer(world, pos.getX() + 0.5, pos.getY() + 50, pos.getZ() + 0.5,
caster, (int)(600 * modifiers.get(WizardryItems.duration_upgrade)),
modifiers.get(SpellModifiers.DAMAGE));
hammer.motionX = 0;
hammer.motionY = -2;
hammer.motionZ = 0;
world.spawnEntity(hammer);
}
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_SUMMONING, 3.0f, 1.0f);
return true;
}
}
return false;
protected void addConstructExtras(EntityHammer construct, EntityLivingBase caster, SpellModifiers modifiers){
construct.motionY = -2;
}
}