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
@@ -7,133 +7,69 @@ import electroblob.wizardry.registry.WizardryBlocks;
import electroblob.wizardry.registry.WizardryItems;
import electroblob.wizardry.tileentity.TileEntityTimer;
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.player.EntityPlayer;
import net.minecraft.init.SoundEvents;
import net.minecraft.item.EnumAction;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.EnumHand;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.util.math.RayTraceResult;
import net.minecraft.world.World;
public class Cobwebs extends Spell {
public class Cobwebs extends SpellRay {
private static final int baseDuration = 400;
private static final int BASE_DURATION = 400;
public Cobwebs(){
super(Tier.ADVANCED, 30, Element.EARTH, "cobwebs", SpellType.ATTACK, 70, EnumAction.NONE, false);
super("cobwebs", Tier.ADVANCED, Element.EARTH, SpellType.ATTACK, 30, 70, false, 12, SoundEvents.BLOCK_LAVA_EXTINGUISH);
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){
boolean flag = false;
pos = pos.offset(side);
RayTraceResult rayTrace = WizardryUtilities.rayTrace(12 * modifiers.get(WizardryItems.range_upgrade), world,
caster, true);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(BASE_DURATION * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
if(rayTrace != null && rayTrace.typeOfHit == RayTraceResult.Type.BLOCK){
for(EnumFacing facing : EnumFacing.values()){
boolean flag = false;
BlockPos pos1 = pos.offset(facing);
BlockPos pos = rayTrace.getBlockPos().offset(rayTrace.sideHit);
if(world.isAirBlock(pos)){
if(world.isAirBlock(pos1)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
world.setBlockState(pos1, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos1) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos1))
.setLifetime((int)(BASE_DURATION * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
for(EnumFacing side : EnumFacing.values()){
BlockPos pos1 = pos.offset(side);
if(world.isAirBlock(pos1)){
if(!world.isRemote){
world.setBlockState(pos1, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos1) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos1))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
}
if(flag){
caster.swingArm(hand);
WizardryUtilities.playSoundAtPlayer(caster, SoundEvents.BLOCK_LAVA_EXTINGUISH, 1.0f, 1.0f);
return true;
}
}
return false;
return flag;
}
@Override
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
SpellModifiers modifiers){
if(target != null){
int x = MathHelper.floor(target.posX);
int y = (int)target.getEntityBoundingBox().minY;
int z = MathHelper.floor(target.posZ);
boolean flag = false;
BlockPos pos = new BlockPos(x, y, z);
if(world.isAirBlock(pos)){
if(!world.isRemote){
world.setBlockState(pos, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
for(EnumFacing side : EnumFacing.values()){
BlockPos pos1 = pos.offset(side);
if(world.isAirBlock(pos1)){
if(!world.isRemote){
world.setBlockState(pos1, WizardryBlocks.vanishing_cobweb.getDefaultState());
if(world.getTileEntity(pos1) instanceof TileEntityTimer){
((TileEntityTimer)world.getTileEntity(pos1))
.setLifetime((int)(baseDuration * modifiers.get(WizardryItems.duration_upgrade)));
}
}
flag = true;
}
}
if(flag){
caster.swingArm(hand);
caster.playSound(SoundEvents.BLOCK_LAVA_EXTINGUISH, 1.0f, 1.0f);
return true;
}
}
protected boolean onMiss(World world, EntityLivingBase caster, int ticksInUse, SpellModifiers modifiers){
return false;
}
@Override
public boolean canBeCastByNPCs(){
return true;
}
}