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
@@ -6,100 +6,66 @@ import electroblob.wizardry.constants.Tier;
import electroblob.wizardry.registry.WizardryAdvancementTriggers;
import electroblob.wizardry.util.SpellModifiers;
import electroblob.wizardry.util.WizardryUtilities;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.effect.EntityLightningBolt;
import net.minecraft.entity.monster.EntityCreeper;
import net.minecraft.entity.passive.EntityPig;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.EnumAction;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumHand;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
import net.minecraftforge.event.entity.EntityStruckByLightningEvent;
import net.minecraftforge.fml.common.Mod;
import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
@Mod.EventBusSubscriber
public class LightningBolt extends Spell {
public class LightningBolt extends SpellRay {
/** The NBT key used to store the UUID of the player that summoned the lightning bolt. Used for achievements. */
public static final String NBT_KEY = "summoningPlayer";
public LightningBolt(){
super(Tier.ADVANCED, 40, Element.LIGHTNING, "lightning_bolt", SpellType.ATTACK, 80, EnumAction.NONE, false);
super("lightning_bolt", Tier.ADVANCED, Element.LIGHTNING, SpellType.ATTACK, 40, 80, false, 200, null);
this.ignoreEntities(true);
}
@Override public boolean doesSpellRequirePacket(){ return false; }
@Override
public boolean doesSpellRequirePacket(){
protected boolean onEntityHit(World world, Entity target, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
public boolean cast(World world, EntityPlayer caster, EnumHand hand, int ticksInUse, SpellModifiers modifiers){
protected boolean onBlockHit(World world, BlockPos pos, EnumFacing side, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
if(world.canBlockSeeSky(pos.up())){
RayTraceResult rayTrace = WizardryUtilities.rayTrace(200, world, caster, false);
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(),
pos.getZ(), false);
world.addWeatherEffect(entitylightning);
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
BlockPos pos = rayTrace.getBlockPos();
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// TODO: Remove this requirement?
if(world.canBlockSeeSky(pos.up())){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, pos.getX(), pos.getY(),
pos.getZ(), false);
world.addWeatherEffect(entitylightning);
// Code for eventhandler recognition; for achievements and such like. Left in for future use.
// Code for eventhandler recognition for achievements
if(caster instanceof EntityPlayer){
NBTTagCompound entityNBT = entitylightning.getEntityData();
entityNBT.setUniqueId(NBT_KEY, caster.getUniqueID());
}
caster.swingArm(hand);
return true;
}
}
return true;
}
return false;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
int x = (int)target.posX;
int y = (int)target.posY;
int z = (int)target.posZ;
// Not sure why it is up 1 but it has to be for canBlockSeeSky to work properly.
// TODO: Remove this requirement?
if(world.canBlockSeeSky(new BlockPos(x, y, z))){
if(!world.isRemote){
EntityLightningBolt entitylightning = new EntityLightningBolt(world, x, y, z, false);
world.addWeatherEffect(entitylightning);
}
caster.swingArm(hand);
return true;
}
}
protected boolean onMiss(World world, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
@SubscribeEvent
public static void onEntityStruckByLightningEvent(EntityStruckByLightningEvent event){
@@ -116,6 +82,6 @@ public class LightningBolt extends Spell {
WizardryAdvancementTriggers.frankenstein.triggerFor(player);
}
}
}
}