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
@@ -1,4 +1,4 @@
package electroblob.wizardry.spell;
package electroblob.wizardry.spell;
import electroblob.wizardry.constants.Element;
import electroblob.wizardry.constants.SpellType;
@@ -10,54 +10,54 @@ import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.item.EnumAction;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumParticleTypes;
import net.minecraft.world.World;
public class Earthquake extends Spell {
public class Earthquake extends SpellConstruct<EntityEarthquake> {
public Earthquake(){
super(Tier.MASTER, 75, Element.EARTH, "earthquake", SpellType.ATTACK, 250, EnumAction.NONE, false);
super("earthquake", Tier.MASTER, Element.EARTH, SpellType.ATTACK, 75, 250, EnumAction.NONE, EntityEarthquake::new, -1, WizardrySounds.SPELL_EARTHQUAKE);
this.soundValues(2, 1, 0);
this.overlap(true);
this.floor(true);
}
// This one spawns particles
@Override public boolean doesSpellRequirePacket(){ return true; }
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
protected void addConstructExtras(EntityEarthquake construct, EntityLivingBase caster, SpellModifiers modifiers){
construct.lifetime = (int)(20 * modifiers.get(WizardryItems.blast_upgrade));
}
@Override
protected boolean spawnConstruct(World world, double x, double y, double z, EntityLivingBase caster, SpellModifiers modifiers){
// TODO: Couldn't this be moved to EntityEarthquake?
if(world.isRemote){
if(caster.onGround){
world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX,
caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0);
if(!world.isRemote){
world.spawnEntity(new EntityEarthquake(world, caster.posX, caster.getEntityBoundingBox().minY,
caster.posZ, caster, (int)(20 * modifiers.get(WizardryItems.blast_upgrade)),
modifiers.get(SpellModifiers.DAMAGE)));
}else{
double particleX, particleZ;
world.spawnParticle(EnumParticleTypes.EXPLOSION_LARGE, caster.posX,
caster.getEntityBoundingBox().minY + 0.1, caster.posZ, 0, 0, 0);
for(int i=0; i<40; i++){
double particleX, particleZ;
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
for(int i = 0; i < 40; i++){
particleX = caster.posX - 1.0d + 2 * world.rand.nextDouble();
particleZ = caster.posZ - 1.0d + 2 * world.rand.nextDouble();
IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster);
if(block != null){
world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY,
particleZ, particleX - caster.posX, 0, particleZ - caster.posZ,
Block.getStateId(block));
}
IBlockState block = WizardryUtilities.getBlockEntityIsStandingOn(caster);
if(block != null){
world.spawnParticle(EnumParticleTypes.BLOCK_DUST, particleX, caster.getEntityBoundingBox().minY,
particleZ, particleX - caster.posX, 0, particleZ - caster.posZ,
Block.getStateId(block));
}
}
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_EARTHQUAKE, 2, 1);
caster.swingArm(hand);
return true;
}
return false;
return super.spawnConstruct(world, x, y, z, caster, modifiers);
}
}