Move target position references inside null checks; fixes #13
This commit is contained in:
@@ -79,15 +79,15 @@ public class FlameRay extends Spell {
|
|||||||
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
|
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
|
||||||
SpellModifiers modifiers){
|
SpellModifiers modifiers){
|
||||||
|
|
||||||
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ)
|
|
||||||
.normalize();
|
|
||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
|
|
||||||
|
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize();
|
||||||
|
|
||||||
target.setFire(10);
|
target.setFire(10);
|
||||||
WizardryUtilities.attackEntityWithoutKnockback(target,
|
WizardryUtilities.attackEntityWithoutKnockback(target,
|
||||||
MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE),
|
MagicDamage.causeDirectMagicDamage(caster, DamageType.FIRE),
|
||||||
3.0f * modifiers.get(SpellModifiers.DAMAGE));
|
3.0f * modifiers.get(SpellModifiers.DAMAGE));
|
||||||
}
|
|
||||||
if(world.isRemote){
|
if(world.isRemote){
|
||||||
for(int i = 0; i < 20; i++){
|
for(int i = 0; i < 20; i++){
|
||||||
double x1 = caster.posX + vec.x * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
|
double x1 = caster.posX + vec.x * i / 2 + world.rand.nextFloat() / 5 - 0.1f;
|
||||||
@@ -104,13 +104,18 @@ public class FlameRay extends Spell {
|
|||||||
vec.z * modifiers.get(WizardryItems.range_upgrade), 0);
|
vec.z * modifiers.get(WizardryItems.range_upgrade), 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ticksInUse % 16 == 0){
|
if(ticksInUse % 16 == 0){
|
||||||
if(ticksInUse == 0) caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
|
if(ticksInUse == 0) caster.playSound(SoundEvents.ENTITY_BLAZE_SHOOT, 1, 1);
|
||||||
caster.playSound(WizardrySounds.SPELL_LOOP_FIRE, 0.5F, 1.0f);
|
caster.playSound(WizardrySounds.SPELL_LOOP_FIRE, 0.5F, 1.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCastByNPCs(){
|
public boolean canBeCastByNPCs(){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -72,17 +72,17 @@ public class LifeDrain extends Spell {
|
|||||||
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
|
public boolean cast(World world, EntityLiving caster, EnumHand hand, int ticksInUse, EntityLivingBase target,
|
||||||
SpellModifiers modifiers){
|
SpellModifiers modifiers){
|
||||||
|
|
||||||
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ)
|
|
||||||
.normalize();
|
|
||||||
|
|
||||||
if(target != null){
|
if(target != null){
|
||||||
|
|
||||||
|
Vec3d vec = new Vec3d(target.posX - caster.posX, target.posY - caster.posY, target.posZ - caster.posZ).normalize();
|
||||||
|
|
||||||
if(ticksInUse % 12 == 0){
|
if(ticksInUse % 12 == 0){
|
||||||
WizardryUtilities.attackEntityWithoutKnockback(target,
|
WizardryUtilities.attackEntityWithoutKnockback(target,
|
||||||
MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
|
MagicDamage.causeDirectMagicDamage(caster, DamageType.MAGIC),
|
||||||
2.0f * modifiers.get(SpellModifiers.DAMAGE));
|
2.0f * modifiers.get(SpellModifiers.DAMAGE));
|
||||||
caster.heal(1);
|
caster.heal(1);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if(world.isRemote){
|
if(world.isRemote){
|
||||||
for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
|
for(int i = 5; i < (int)(25 * modifiers.get(WizardryItems.range_upgrade)); i += 2){
|
||||||
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
|
// I figured it out! when on client side, entityplayer.posY is at the eyes, not the feet!
|
||||||
@@ -99,6 +99,7 @@ public class LifeDrain extends Spell {
|
|||||||
-0.05 * vec.y * i, -0.05 * vec.z * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
|
-0.05 * vec.y * i, -0.05 * vec.z * i, 8 + world.rand.nextInt(6), 0.5f, 0.0f, 0.0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(ticksInUse % 18 == 0){
|
if(ticksInUse % 18 == 0){
|
||||||
if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_SUMMONING, 1.0F, 0.6f);
|
if(ticksInUse == 0) caster.playSound(WizardrySounds.SPELL_SUMMONING, 1.0F, 0.6f);
|
||||||
caster.playSound(WizardrySounds.SPELL_LOOP_CRACKLE, 2.0F, 1.0f);
|
caster.playSound(WizardrySounds.SPELL_LOOP_CRACKLE, 2.0F, 1.0f);
|
||||||
@@ -107,6 +108,9 @@ public class LifeDrain extends Spell {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canBeCastByNPCs(){
|
public boolean canBeCastByNPCs(){
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user