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
@@ -17,71 +17,55 @@ import net.minecraft.world.World;
public class Decoy extends Spell {
public Decoy(){
super(Tier.ADVANCED, 40, Element.SORCERY, "decoy", SpellType.UTILITY, 200, EnumAction.BOW, false);
super("decoy", Tier.ADVANCED, Element.SORCERY, SpellType.UTILITY, 40, 200, EnumAction.BOW, false);
}
@Override public boolean canBeCastByNPCs(){ return true; }
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
// Determines whether the caster moves left and the decoy moves right, or vice versa.
// Uses the synchronised entity id to ensure it is consistent on client and server, but not always the same.
double splitSpeed = caster.getEntityId() % 2 == 0 ? 0.3 : -0.3;
if(!world.isRemote){
EntityDecoy decoy = new EntityDecoy(world, caster.posX, caster.posY, caster.posZ, caster, 600);
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
decoy.addVelocity(-caster.getLookVec().z * splitSpeed, 0, caster.getLookVec().x * splitSpeed);
// Ignores the show names setting, since this would allow a player to easily detect a decoy
decoy.setCustomNameTag(caster.getName());
world.spawnEntity(decoy);
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
caster.posZ, world, EntityLiving.class)){
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
}
}
}
caster.addVelocity(caster.getLookVec().z * splitSpeed, 0, -caster.getLookVec().x * splitSpeed);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F,
0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
spawnDecoy(world, caster, modifiers, splitSpeed);
WizardryUtilities.playSoundAtPlayer(caster, WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target, SpellModifiers modifiers){
// Determines whether the caster moves left and the decoy moves right, or vice versa.
double splitSpeed = world.rand.nextBoolean() ? 0.3 : -0.3;
if(!world.isRemote){
EntityDecoy decoy = new EntityDecoy(world, caster.posX, caster.posY, caster.posZ, caster, 600);
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
decoy.addVelocity(-caster.getLookVec().z * splitSpeed, 0, caster.getLookVec().x * splitSpeed);
world.spawnEntity(decoy);
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
caster.posZ, world, EntityLiving.class)){
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.DAMAGE))) < 3){
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
}
}
}
caster.addVelocity(caster.getLookVec().z * splitSpeed, 0, -caster.getLookVec().x * splitSpeed);
spawnDecoy(world, caster, modifiers, splitSpeed);
caster.playSound(WizardrySounds.SPELL_CONJURATION, 1.0F, 0.4F / (world.rand.nextFloat() * 0.4F + 0.8F));
return true;
}
private void spawnDecoy(World world, EntityLivingBase caster, SpellModifiers modifiers, double splitSpeed){
@Override
public boolean canBeCastByNPCs(){
return true;
if(!world.isRemote){
EntityDecoy decoy = new EntityDecoy(world);
decoy.setCaster(caster);
decoy.setLifetime(600);
decoy.setLocationAndAngles(caster.posX, caster.posY, caster.posZ, caster.rotationYaw, caster.rotationPitch);
decoy.addVelocity(-caster.getLookVec().z * splitSpeed, 0, caster.getLookVec().x * splitSpeed);
// Ignores the show names setting, since this would allow a player to easily detect a decoy
// Instead, a decoy player has its caster's name tag shown permanently and non-player decoys have nothing
if(caster instanceof EntityPlayer) decoy.setCustomNameTag(caster.getName());
world.spawnEntity(decoy);
// Tricks any mobs that are targeting the caster into targeting the decoy instead.
for(EntityLiving creature : WizardryUtilities.getEntitiesWithinRadius(16, caster.posX, caster.posY,
caster.posZ, world, EntityLiving.class)){
// More likely to trick mobs the higher the damage multiplier. Starts off at 50%.
if(world.rand.nextInt((int)(6 * modifiers.get(SpellModifiers.POTENCY))) < 3){
if(creature.getAttackTarget() == caster) creature.setAttackTarget(decoy);
}
}
}
caster.addVelocity(caster.getLookVec().z * splitSpeed, 0, -caster.getLookVec().x * splitSpeed);
}
}