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:
@@ -1,7 +1,6 @@
|
||||
package electroblob.wizardry.entity.projectile;
|
||||
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
@@ -21,29 +20,16 @@ public abstract class EntityBomb extends EntityMagicProjectile {
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityBomb(World world, EntityLivingBase thrower){
|
||||
super(world, thrower);
|
||||
}
|
||||
|
||||
public EntityBomb(World world, EntityLivingBase thrower, float damageMultiplier, float blastMultiplier){
|
||||
super(world, thrower, damageMultiplier);
|
||||
this.blastMultiplier = blastMultiplier;
|
||||
}
|
||||
|
||||
public EntityBomb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf buffer){
|
||||
super.writeSpawnData(buffer);
|
||||
buffer.writeFloat(blastMultiplier);
|
||||
super.writeSpawnData(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf buffer){
|
||||
super.readSpawnData(buffer);
|
||||
blastMultiplier = buffer.readFloat();
|
||||
super.readSpawnData(buffer);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -14,30 +14,14 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityDarknessOrb extends EntityMagicProjectile {
|
||||
|
||||
public EntityDarknessOrb(World par1World){
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityDarknessOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
}
|
||||
|
||||
public EntityDarknessOrb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
public EntityDarknessOrb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getSpeed(){
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult RayTraceResult){
|
||||
Entity target = RayTraceResult.entityHit;
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
Entity target = rayTrace.entityHit;
|
||||
|
||||
if(target != null && !MagicDamage.isEntityImmune(DamageType.WITHER, target)){
|
||||
float damage = 8 * damageMultiplier;
|
||||
@@ -79,10 +63,8 @@ public class EntityDarknessOrb extends EntityMagicProjectile {
|
||||
this.motionZ /= 0.99;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of gravity to apply to the thrown entity with each tick.
|
||||
*/
|
||||
protected float getGravityVelocity(){
|
||||
return 0.0F;
|
||||
@Override
|
||||
public boolean hasNoGravity(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
package electroblob.wizardry.entity.projectile;
|
||||
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.MobEffects;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
@@ -11,36 +9,17 @@ import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityDart extends EntityMagicArrow {
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
|
||||
/** Creates a new dart in the given world. */
|
||||
public EntityDart(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityDart(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
@Override public double getDamage(){ return 4.0d; }
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityDart(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doGravity(){ return true; }
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityDart(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doDeceleration(){ return true; }
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
@@ -70,28 +49,6 @@ public class EntityDart extends EntityMagicArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage(){
|
||||
return 4.0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageType getDamageType(){
|
||||
return DamageType.MAGIC;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDeceleration(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit(){
|
||||
|
||||
}
|
||||
protected void entityInit(){}
|
||||
|
||||
}
|
||||
@@ -3,27 +3,15 @@ package electroblob.wizardry.entity.projectile;
|
||||
import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityFirebolt extends EntityMagicProjectile {
|
||||
public EntityFirebolt(World par1World){
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityFirebolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
}
|
||||
|
||||
public EntityFirebolt(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
|
||||
public EntityFirebolt(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -72,17 +60,11 @@ public class EntityFirebolt extends EntityMagicProjectile {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of gravity to apply to the thrown entity with each tick.
|
||||
*/
|
||||
@Override
|
||||
protected float getGravityVelocity(){
|
||||
return 0.0F;
|
||||
public boolean hasNoGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this entity should be rendered as on fire.
|
||||
*/
|
||||
@Override
|
||||
public boolean canRenderOnFire(){
|
||||
return false;
|
||||
|
||||
@@ -16,27 +16,14 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityFirebomb extends EntityBomb {
|
||||
|
||||
public EntityFirebomb(World par1World){
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityFirebomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier);
|
||||
}
|
||||
|
||||
public EntityFirebomb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
public EntityFirebomb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
Entity entityHit = rayTrace.entityHit;
|
||||
|
||||
if(entityHit != null){
|
||||
// This is if the firebomb gets a direct hit
|
||||
|
||||
@@ -1,44 +1,17 @@
|
||||
package electroblob.wizardry.entity.projectile;
|
||||
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityForceArrow extends EntityMagicArrow {
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new force arrow in the given world. */
|
||||
public EntityForceArrow(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityForceArrow(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityForceArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityForceArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST, 1.0F, 1.0F);
|
||||
|
||||
@@ -9,40 +9,17 @@ import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityForceOrb extends EntityMagicProjectile {
|
||||
|
||||
/**
|
||||
* The entity blast multiplier. In this particular case, it doesn't need syncing, so this class doesn't extend
|
||||
* EntityBlastProjectile.
|
||||
*/
|
||||
public float blastMultiplier;
|
||||
|
||||
public EntityForceOrb(World par1World){
|
||||
super(par1World);
|
||||
public class EntityForceOrb extends EntityBomb {
|
||||
|
||||
public EntityForceOrb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityForceOrb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
this.blastMultiplier = blastMultiplier;
|
||||
}
|
||||
|
||||
public EntityForceOrb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
|
||||
if(par1RayTraceResult.entityHit != null){
|
||||
@@ -96,16 +73,5 @@ public class EntityForceOrb extends EntityMagicProjectile {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readEntityFromNBT(NBTTagCompound nbttagcompound){
|
||||
super.readEntityFromNBT(nbttagcompound);
|
||||
blastMultiplier = nbttagcompound.getFloat("blastMultiplier");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound nbttagcompound){
|
||||
super.writeEntityToNBT(nbttagcompound);
|
||||
nbttagcompound.setFloat("blastMultiplier", blastMultiplier);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -21,26 +21,11 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityIceCharge extends EntityBomb {
|
||||
|
||||
public EntityIceCharge(World par1World){
|
||||
super(par1World);
|
||||
public EntityIceCharge(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityIceCharge(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier);
|
||||
}
|
||||
|
||||
public EntityIceCharge(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
|
||||
@@ -62,7 +47,7 @@ public class EntityIceCharge extends EntityBomb {
|
||||
for(int i = 0; i < 30 * blastMultiplier; i++){
|
||||
|
||||
ParticleBuilder.create(Type.ICE, rand, this.posX, this.posY, this.posZ, 2 * blastMultiplier, false)
|
||||
.lifetime(35).spawn(world);
|
||||
.lifetime(35).gravity(true).spawn(world);
|
||||
|
||||
float brightness = 0.4f + rand.nextFloat() * 0.5f;
|
||||
ParticleBuilder.create(Type.DARK_MAGIC, rand, this.posX, this.posY, this.posZ, 2 * blastMultiplier, false)
|
||||
@@ -118,11 +103,12 @@ public class EntityIceCharge extends EntityBomb {
|
||||
double dx = rand.nextDouble() - 0.5;
|
||||
double dy = rand.nextDouble() - 0.5;
|
||||
double dz = rand.nextDouble() - 0.5;
|
||||
EntityIceShard iceshard = new EntityIceShard(world, this.posX + dx, this.posY + dy, this.posZ + dz);
|
||||
EntityIceShard iceshard = new EntityIceShard(world);
|
||||
iceshard.setPosition(this.posX + dx, this.posY + dy, this.posZ + dz);
|
||||
iceshard.motionX = dx;
|
||||
iceshard.motionY = dy;
|
||||
iceshard.motionZ = dz;
|
||||
iceshard.setShootingEntity(this.getThrower());
|
||||
iceshard.setCaster(this.getThrower());
|
||||
iceshard.damageMultiplier = this.damageMultiplier;
|
||||
world.spawnEntity(iceshard);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
@@ -13,40 +12,23 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityIceLance extends EntityMagicArrow {
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new ice lance in the given world. */
|
||||
public EntityIceLance(World world){
|
||||
super(world);
|
||||
this.setKnockbackStrength(1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityIceLance(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
this.setKnockbackStrength(1);
|
||||
}
|
||||
@Override public double getDamage(){ return 10.0d; }
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityIceLance(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
this.setKnockbackStrength(1);
|
||||
}
|
||||
@Override public DamageType getDamageType(){ return DamageType.FROST; }
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityIceLance(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
this.setKnockbackStrength(1);
|
||||
}
|
||||
@Override public boolean doGravity(){ return true; }
|
||||
|
||||
@Override public boolean doDeceleration(){ return true; }
|
||||
|
||||
@Override public boolean doOverpenetration(){ return true; }
|
||||
|
||||
@Override public boolean canRenderOnFire(){ return false; }
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
@@ -58,11 +40,6 @@ public class EntityIceLance extends EntityMagicArrow {
|
||||
this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickInAir(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHit(){
|
||||
// Adds a particle effect when the ice lance hits a block.
|
||||
@@ -78,43 +55,6 @@ public class EntityIceLance extends EntityMagicArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickInGround(){
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage(){
|
||||
return 10.0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageType getDamageType(){
|
||||
return DamageType.FROST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDeceleration(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doOverpenetration(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderOnFire(){
|
||||
return false;
|
||||
}
|
||||
protected void entityInit(){}
|
||||
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
@@ -13,36 +12,20 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityIceShard extends EntityMagicArrow {
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new ice shard in the given world. */
|
||||
public EntityIceShard(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityIceShard(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
@Override public double getDamage(){ return 6.0d; }
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityIceShard(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
}
|
||||
@Override public DamageType getDamageType(){ return DamageType.FROST; }
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityIceShard(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doGravity(){ return true; }
|
||||
|
||||
@Override public boolean doDeceleration(){ return true; }
|
||||
|
||||
@Override public boolean canRenderOnFire(){ return false; }
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
@@ -54,18 +37,13 @@ public class EntityIceShard extends EntityMagicArrow {
|
||||
this.playSound(SoundEvents.ENTITY_GENERIC_HURT, 1.0F, 1.2F / (this.rand.nextFloat() * 0.2F + 0.9F));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tickInAir(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockHit(){
|
||||
// Adds a particle effect when the ice shard hits a block.
|
||||
if(this.world.isRemote){
|
||||
for(int j = 0; j < 10; j++){
|
||||
ParticleBuilder.create(Type.ICE, this.rand, this.posX, this.posY, this.posZ, 0.5, true)
|
||||
.lifetime(20 + rand.nextInt(10)).spawn(world);
|
||||
.lifetime(20 + rand.nextInt(10)).gravity(true).spawn(world);
|
||||
}
|
||||
}
|
||||
// Parameters for sound: sound event name, volume, pitch.
|
||||
@@ -74,33 +52,6 @@ public class EntityIceShard extends EntityMagicArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage(){
|
||||
return 6.0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageType getDamageType(){
|
||||
return DamageType.FROST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDeceleration(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit(){
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRenderOnFire(){
|
||||
return false;
|
||||
}
|
||||
protected void entityInit(){}
|
||||
|
||||
}
|
||||
@@ -4,42 +4,23 @@ import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityLightningArrow extends EntityMagicArrow {
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new lightning arrow in the given world. */
|
||||
public EntityLightningArrow(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityLightningArrow(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
@Override public double getDamage(){ return 7.0d; }
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityLightningArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
}
|
||||
@Override public DamageType getDamageType(){ return DamageType.SHOCK; }
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityLightningArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doGravity(){ return false; }
|
||||
|
||||
@Override public boolean doDeceleration(){ return false; }
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
@@ -67,28 +48,6 @@ public class EntityLightningArrow extends EntityMagicArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage(){
|
||||
return 7.0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DamageType getDamageType(){
|
||||
return DamageType.SHOCK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGravity(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDeceleration(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit(){
|
||||
|
||||
}
|
||||
protected void entityInit(){}
|
||||
|
||||
}
|
||||
@@ -15,29 +15,12 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityLightningDisc extends EntityMagicProjectile {
|
||||
|
||||
public EntityLightningDisc(World par1World){
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityLightningDisc(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
}
|
||||
|
||||
public EntityLightningDisc(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
public EntityLightningDisc(World world){
|
||||
super(world);
|
||||
this.width = 2.0f;
|
||||
this.height = 0.5f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getSpeed(){
|
||||
return 1.2f;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult result){
|
||||
|
||||
@@ -65,7 +48,7 @@ public class EntityLightningDisc extends EntityMagicProjectile {
|
||||
for(int i = 0; i < 8; i++){
|
||||
// TODO: Why are the x and z parameters different?
|
||||
ParticleBuilder.create(Type.SPARK).pos(this.posX + rand.nextFloat() * 2 - 1,
|
||||
this.posY, this.posZ + rand.nextFloat() - 0.5).spawn(world);
|
||||
this.posY, this.posZ + rand.nextFloat() * 2 - 1).spawn(world);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -105,8 +88,8 @@ public class EntityLightningDisc extends EntityMagicProjectile {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected float getGravityVelocity(){
|
||||
return 0.0F;
|
||||
public boolean hasNoGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -59,7 +59,7 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
/** Seems to be some sort of timer for animating an arrow. */
|
||||
public int arrowShake;
|
||||
/** The owner of this arrow. */
|
||||
private WeakReference<EntityLivingBase> shootingEntity;
|
||||
private WeakReference<EntityLivingBase> caster;
|
||||
/**
|
||||
* The UUID of the caster. Note that this is only for loading purposes; during normal updates the actual entity
|
||||
* instance is stored (so that getEntityByUUID is not called constantly), so this will not always be synced (this is
|
||||
@@ -70,87 +70,74 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
int ticksInAir;
|
||||
/** The amount of knockback an arrow applies when it hits a mob. */
|
||||
private int knockbackStrength;
|
||||
/**
|
||||
* The damage multiplier for the arrow. Normally this isn't set directly, since it can be done via the constructor.
|
||||
* An exception is where other entities need to pass in their multipliers, e.g. ice charge.
|
||||
*/
|
||||
/** The damage multiplier for the projectile. */
|
||||
public float damageMultiplier = 1.0f;
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new projectile in the given world. */
|
||||
public EntityMagicArrow(World world){
|
||||
super(world);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityMagicArrow(World world, double x, double y, double z){
|
||||
super(world);
|
||||
this.setSize(0.5F, 0.5F);
|
||||
this.setPosition(x, y, z);
|
||||
// yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway.
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the aimingError parameter. For reference, skeletons set this to
|
||||
* 10 on easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityMagicArrow(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world);
|
||||
this.shootingEntity = new WeakReference<EntityLivingBase>(caster);
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
|
||||
this.posY = caster.posY + (double)caster.getEyeHeight() - 0.10000000149011612D;
|
||||
double d0 = target.posX - caster.posX;
|
||||
double d1 = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0F) - this.posY
|
||||
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0F) - this.posY;
|
||||
double d2 = target.posZ - caster.posZ;
|
||||
double d3 = (double)MathHelper.sqrt(d0 * d0 + d2 * d2);
|
||||
|
||||
if(d3 >= 1.0E-7D){
|
||||
float f2 = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
|
||||
float f3 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
|
||||
double d4 = d0 / d3;
|
||||
double d5 = d2 / d3;
|
||||
this.setLocationAndAngles(caster.posX + d4, this.posY, caster.posZ + d5, f2, f3);
|
||||
// yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway.
|
||||
|
||||
// f4 depends on the horizontal distance between the two entities and accounts for bullet drop,
|
||||
// but of course if gravity is ignored this should be 0.
|
||||
float bulletDropCompensation = this.doGravity() ? (float)d3 * 0.2F : 0;
|
||||
this.shoot(d0, d1 + (double)bulletDropCompensation, d2, speed, aimingError);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. <b>Use this
|
||||
* constructor for normal, player-cast spells.
|
||||
*/
|
||||
public EntityMagicArrow(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world);
|
||||
this.shootingEntity = new WeakReference<EntityLivingBase>(caster);
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
|
||||
this.setSize(0.5F, 0.5F);
|
||||
|
||||
// Initialiser methods
|
||||
|
||||
/** Sets the shooter of the projectile to the given caster, positions the projctile at the given caster's eyes and
|
||||
* aims it in the direction they are looking with the given speed. */
|
||||
public void aim(EntityLivingBase caster, float speed){
|
||||
|
||||
this.setCaster(caster);
|
||||
|
||||
this.setLocationAndAngles(caster.posX, caster.posY + (double)caster.getEyeHeight(), caster.posZ,
|
||||
caster.rotationYaw, caster.rotationPitch);
|
||||
|
||||
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
|
||||
this.posY -= 0.10000000149011612D;
|
||||
this.posZ -= (double)(MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
|
||||
|
||||
this.setPosition(this.posX, this.posY, this.posZ);
|
||||
|
||||
// yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway.
|
||||
this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI)
|
||||
* MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
|
||||
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
|
||||
this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI)
|
||||
* MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
|
||||
this.motionY = (double)(-MathHelper.sin(this.rotationPitch / 180.0F * (float)Math.PI));
|
||||
|
||||
this.shoot(this.motionX, this.motionY, this.motionZ, speed * 1.5F, 1.0F);
|
||||
}
|
||||
|
||||
/** Sets the shooter of the projectile to the given caster, positions the projctile at the given caster's eyes and
|
||||
* aims it at the given target with the given speed. The trajectory will be altered slightly by a random amount
|
||||
* determined by the aimingError parameter. For reference, skeletons set this to 10 on easy, 6 on normal and 2 on hard
|
||||
* difficulty. */
|
||||
public void aim(EntityLivingBase caster, Entity target, float speed, float aimingError){
|
||||
|
||||
this.setCaster(caster);
|
||||
|
||||
this.posY = caster.posY + (double)caster.getEyeHeight() - 0.1d;
|
||||
double dx = target.posX - caster.posX;
|
||||
double dy = this.doGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY
|
||||
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY;
|
||||
double dz = target.posZ - caster.posZ;
|
||||
double horizontalDistance = (double)MathHelper.sqrt(dx * dx + dz * dz);
|
||||
|
||||
if(horizontalDistance >= 1.0E-7D){
|
||||
float yaw = (float)(Math.atan2(dz, dx) * 180.0d / Math.PI) - 90.0f;
|
||||
float pitch = (float)(-(Math.atan2(dy, horizontalDistance) * 180.0d / Math.PI));
|
||||
double dxNormalised = dx / horizontalDistance;
|
||||
double dzNormalised = dz / horizontalDistance;
|
||||
this.setLocationAndAngles(caster.posX + dxNormalised, this.posY, caster.posZ + dzNormalised, yaw, pitch);
|
||||
// yOffset was set to 0 here, but that has been replaced by getYOffset(), which returns 0 in Entity anyway.
|
||||
|
||||
// Depends on the horizontal distance between the two entities and accounts for bullet drop,
|
||||
// but of course if gravity is ignored this should be 0 since there is no bullet drop.
|
||||
float bulletDropCompensation = this.doGravity() ? (float)horizontalDistance * 0.2f : 0;
|
||||
this.shoot(dx, dy + (double)bulletDropCompensation, dz, speed, aimingError);
|
||||
}
|
||||
}
|
||||
|
||||
// Property getters (to be overridden by subclasses)
|
||||
|
||||
/** Subclasses must override this to set their own base damage. */
|
||||
public abstract double getDamage();
|
||||
|
||||
@@ -180,86 +167,52 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
return false;
|
||||
}
|
||||
|
||||
// Setters and getters
|
||||
|
||||
/** Sets the amount of knockback the projectile applies when it hits a mob. */
|
||||
public void setKnockbackStrength(int knockback){
|
||||
this.knockbackStrength = knockback;
|
||||
}
|
||||
|
||||
/**
|
||||
* Similar to setArrowHeading, it's point the throwable entity to a x, y, z direction.
|
||||
* Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the entity
|
||||
* may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported to
|
||||
* another dimension, or this construct simply had no caster in the first place.
|
||||
*/
|
||||
@Override
|
||||
public void shoot(double x, double y, double z, float speed, float randomness){
|
||||
float f2 = MathHelper.sqrt(x * x + y * y + z * z);
|
||||
x /= (double)f2;
|
||||
y /= (double)f2;
|
||||
z /= (double)f2;
|
||||
x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D
|
||||
* (double)randomness;
|
||||
y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D
|
||||
* (double)randomness;
|
||||
z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D
|
||||
* (double)randomness;
|
||||
x *= (double)speed;
|
||||
y *= (double)speed;
|
||||
z *= (double)speed;
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
float f3 = MathHelper.sqrt(x * x + z * z);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
|
||||
this.ticksInGround = 0;
|
||||
public EntityLivingBase getCaster(){
|
||||
return caster == null ? null : caster.get();
|
||||
}
|
||||
|
||||
// There was an override for setPositionAndRotationDirect here, but it was exactly the same as the superclass
|
||||
// method (in Entity), so it was removed since it was redundant.
|
||||
|
||||
/**
|
||||
* Sets the velocity to the args. Args: x, y, z. THIS IS CLIENT SIDE ONLY! DO NOT USE IN COMMON OR SERVER CODE!
|
||||
*/
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_){
|
||||
this.motionX = p_70016_1_;
|
||||
this.motionY = p_70016_3_;
|
||||
this.motionZ = p_70016_5_;
|
||||
|
||||
if(this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F){
|
||||
float f = MathHelper.sqrt(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch;
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
public void setCaster(EntityLivingBase entity){
|
||||
caster = new WeakReference<EntityLivingBase>(entity);
|
||||
}
|
||||
|
||||
// Methods triggered during the update cycle
|
||||
|
||||
/**
|
||||
* Called each tick when the projectile is in a block. Defaults to setDead(), but can be overridden to change the
|
||||
* behaviour.
|
||||
*/
|
||||
public void tickInGround(){
|
||||
/** Called each tick when the projectile is in a block. Defaults to setDead(), but can be overridden to change the
|
||||
* behaviour. */
|
||||
protected void tickInGround(){
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
/** Called each tick when the projectile is in the air. Override to add particles and such like. */
|
||||
public void tickInAir(){
|
||||
}
|
||||
protected void tickInAir(){}
|
||||
|
||||
/** Called when the projectile hits an entity. Override to add potion effects and such like. */
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
}
|
||||
protected void onEntityHit(EntityLivingBase entityHit){}
|
||||
|
||||
/** Called when the projectile hits a block. Override to add sound effects and such like. */
|
||||
public void onBlockHit(){
|
||||
}
|
||||
protected void onBlockHit(){}
|
||||
|
||||
@Override
|
||||
public void onUpdate(){
|
||||
|
||||
super.onUpdate();
|
||||
|
||||
if(this.getShootingEntity() == null && this.casterUUID != null){
|
||||
if(this.getCaster() == null && this.casterUUID != null){
|
||||
Entity entity = WizardryUtilities.getEntityByUUID(world, casterUUID);
|
||||
if(entity instanceof EntityLivingBase){
|
||||
this.shootingEntity = new WeakReference<EntityLivingBase>((EntityLivingBase)entity);
|
||||
this.caster = new WeakReference<EntityLivingBase>((EntityLivingBase)entity);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,7 +273,7 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
for(i = 0; i < list.size(); ++i){
|
||||
Entity entity1 = (Entity)list.get(i);
|
||||
|
||||
if(entity1.canBeCollidedWith() && (entity1 != this.getShootingEntity() || this.ticksInAir >= 5)){
|
||||
if(entity1.canBeCollidedWith() && (entity1 != this.getCaster() || this.ticksInAir >= 5)){
|
||||
f1 = 0.3F;
|
||||
AxisAlignedBB axisalignedbb1 = entity1.getEntityBoundingBox().grow((double)f1, (double)f1,
|
||||
(double)f1);
|
||||
@@ -347,8 +300,8 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
&& raytraceresult.entityHit instanceof EntityPlayer){
|
||||
EntityPlayer entityplayer = (EntityPlayer)raytraceresult.entityHit;
|
||||
|
||||
if(entityplayer.capabilities.disableDamage || this.getShootingEntity() instanceof EntityPlayer
|
||||
&& !((EntityPlayer)this.getShootingEntity()).canAttackPlayer(entityplayer)){
|
||||
if(entityplayer.capabilities.disableDamage || this.getCaster() instanceof EntityPlayer
|
||||
&& !((EntityPlayer)this.getCaster()).canAttackPlayer(entityplayer)){
|
||||
raytraceresult = null;
|
||||
}
|
||||
}
|
||||
@@ -359,11 +312,11 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
if(raytraceresult.entityHit != null){
|
||||
DamageSource damagesource = null;
|
||||
|
||||
if(this.getShootingEntity() == null){
|
||||
if(this.getCaster() == null){
|
||||
damagesource = DamageSource.causeThrownDamage(this, this);
|
||||
}else{
|
||||
damagesource = MagicDamage.causeIndirectMagicDamage(this,
|
||||
(EntityLivingBase)this.getShootingEntity(), this.getDamageType()).setProjectile();
|
||||
(EntityLivingBase)this.getCaster(), this.getDamageType()).setProjectile();
|
||||
}
|
||||
|
||||
if(raytraceresult.entityHit.attackEntityFrom(damagesource,
|
||||
@@ -386,17 +339,17 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
}
|
||||
|
||||
// Thorns enchantment
|
||||
if(this.getShootingEntity() != null
|
||||
&& this.getShootingEntity() instanceof EntityLivingBase){
|
||||
EnchantmentHelper.applyThornEnchantments(entityHit, this.getShootingEntity());
|
||||
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase)this.getShootingEntity(),
|
||||
if(this.getCaster() != null
|
||||
&& this.getCaster() instanceof EntityLivingBase){
|
||||
EnchantmentHelper.applyThornEnchantments(entityHit, this.getCaster());
|
||||
EnchantmentHelper.applyArthropodEnchantments((EntityLivingBase)this.getCaster(),
|
||||
entityHit);
|
||||
}
|
||||
|
||||
if(this.getShootingEntity() != null && raytraceresult.entityHit != this.getShootingEntity()
|
||||
if(this.getCaster() != null && raytraceresult.entityHit != this.getCaster()
|
||||
&& raytraceresult.entityHit instanceof EntityPlayer
|
||||
&& this.getShootingEntity() instanceof EntityPlayerMP){
|
||||
((EntityPlayerMP)this.getShootingEntity()).connection
|
||||
&& this.getCaster() instanceof EntityPlayerMP){
|
||||
((EntityPlayerMP)this.getCaster()).connection
|
||||
.sendPacket(new SPacketChangeGameState(6, 0.0F));
|
||||
}
|
||||
}
|
||||
@@ -497,6 +450,51 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shoot(double x, double y, double z, float speed, float randomness){
|
||||
float f2 = MathHelper.sqrt(x * x + y * y + z * z);
|
||||
x /= (double)f2;
|
||||
y /= (double)f2;
|
||||
z /= (double)f2;
|
||||
x += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness;
|
||||
y += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness;
|
||||
z += this.rand.nextGaussian() * (double)(this.rand.nextBoolean() ? -1 : 1) * 0.007499999832361937D * (double)randomness;
|
||||
x *= (double)speed;
|
||||
y *= (double)speed;
|
||||
z *= (double)speed;
|
||||
this.motionX = x;
|
||||
this.motionY = y;
|
||||
this.motionZ = z;
|
||||
float f3 = MathHelper.sqrt(x * x + z * z);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(x, z) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(y, (double)f3) * 180.0D / Math.PI);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
|
||||
// There was an override for setPositionAndRotationDirect here, but it was exactly the same as the superclass
|
||||
// method (in Entity), so it was removed since it was redundant.
|
||||
|
||||
/** Sets the velocity to the args. Args: x, y, z. THIS IS CLIENT SIDE ONLY! DO NOT USE IN COMMON OR SERVER CODE! */
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void setVelocity(double p_70016_1_, double p_70016_3_, double p_70016_5_){
|
||||
this.motionX = p_70016_1_;
|
||||
this.motionY = p_70016_3_;
|
||||
this.motionZ = p_70016_5_;
|
||||
|
||||
if(this.prevRotationPitch == 0.0F && this.prevRotationYaw == 0.0F){
|
||||
float f = MathHelper.sqrt(p_70016_1_ * p_70016_1_ + p_70016_5_ * p_70016_5_);
|
||||
this.prevRotationYaw = this.rotationYaw = (float)(Math.atan2(p_70016_1_, p_70016_5_) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch = (float)(Math.atan2(p_70016_3_, (double)f) * 180.0D / Math.PI);
|
||||
this.prevRotationPitch = this.rotationPitch;
|
||||
this.prevRotationYaw = this.rotationYaw;
|
||||
this.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
|
||||
this.ticksInGround = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Data reading and writing
|
||||
|
||||
@Override
|
||||
public void writeEntityToNBT(NBTTagCompound tag){
|
||||
tag.setShort("xTile", (short)this.blockX);
|
||||
@@ -512,8 +510,8 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
tag.setByte("shake", (byte)this.arrowShake);
|
||||
tag.setByte("inGround", (byte)(this.inGround ? 1 : 0));
|
||||
tag.setFloat("damageMultiplier", this.damageMultiplier);
|
||||
if(this.getShootingEntity() != null){
|
||||
tag.setUniqueId("casterUUID", this.getShootingEntity().getUniqueID());
|
||||
if(this.getCaster() != null){
|
||||
tag.setUniqueId("casterUUID", this.getCaster().getUniqueID());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -531,58 +529,35 @@ public abstract class EntityMagicArrow extends Entity implements IProjectile, IE
|
||||
this.damageMultiplier = tag.getFloat("damageMultiplier");
|
||||
casterUUID = tag.getUniqueId("casterUUID");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeSpawnData(ByteBuf buffer){
|
||||
if(this.getCaster() != null) buffer.writeInt(this.getCaster().getEntityId());
|
||||
}
|
||||
|
||||
/**
|
||||
* returns if this entity triggers Block.onEntityWalking on the blocks they walk on. used for spiders and wolves to
|
||||
* prevent them from trampling crops
|
||||
*/
|
||||
@Override
|
||||
public void readSpawnData(ByteBuf buffer){
|
||||
if(buffer.isReadable()) this.caster = new WeakReference<EntityLivingBase>(
|
||||
(EntityLivingBase)this.world.getEntityByID(buffer.readInt()));
|
||||
}
|
||||
|
||||
// Miscellaneous overrides
|
||||
|
||||
@Override
|
||||
protected boolean canTriggerWalking(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeAttackedWithItem(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public float getShadowSize(){
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the amount of knockback the arrow applies when it hits a mob.
|
||||
*/
|
||||
public void setKnockbackStrength(int p_70240_1_){
|
||||
this.knockbackStrength = p_70240_1_;
|
||||
}
|
||||
|
||||
/**
|
||||
* If returns false, the item will not inflict any damage against entities.
|
||||
*/
|
||||
public boolean canAttackWithItem(){
|
||||
return false;
|
||||
}
|
||||
|
||||
public void writeSpawnData(ByteBuf buffer){
|
||||
if(this.getShootingEntity() != null) buffer.writeInt(this.getShootingEntity().getEntityId());
|
||||
}
|
||||
|
||||
public void readSpawnData(ByteBuf buffer){
|
||||
if(buffer.isReadable()) this.shootingEntity = new WeakReference<EntityLivingBase>(
|
||||
(EntityLivingBase)this.world.getEntityByID(buffer.readInt()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the EntityLivingBase that created this construct, or null if it no longer exists. Cases where the entity
|
||||
* may no longer exist are: entity died or was deleted, mob despawned, player logged out, entity teleported to
|
||||
* another dimension, or this construct simply had no caster in the first place.
|
||||
*/
|
||||
public EntityLivingBase getShootingEntity(){
|
||||
return shootingEntity == null ? null : shootingEntity.get();
|
||||
}
|
||||
|
||||
public void setShootingEntity(EntityLivingBase entity){
|
||||
shootingEntity = new WeakReference<EntityLivingBase>(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit() {
|
||||
// TODO Auto-generated method stub
|
||||
}
|
||||
protected void entityInit(){}
|
||||
}
|
||||
@@ -2,43 +2,22 @@ package electroblob.wizardry.entity.projectile;
|
||||
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntityMagicMissile extends EntityMagicArrow {
|
||||
|
||||
/** Basic shell constructor. Should only be used by the client. */
|
||||
/** Creates a new magic missile in the given world. */
|
||||
public EntityMagicMissile(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a projectile at position xyz in world, with no motion. Do not create a projectile with this constructor
|
||||
* and then call setVelocity() as that method is, bizarrely, client-side only.
|
||||
*/
|
||||
public EntityMagicMissile(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
@Override public double getDamage(){ return 4.0d; }
|
||||
|
||||
/**
|
||||
* Creates a projectile at the position of the caster, pointing at the given target. The trajectory seems to be
|
||||
* altered slightly by a random amount determined by the last parameter. For reference, skeletons set this to 10 on
|
||||
* easy, 6 on normal and 2 on hard difficulty.
|
||||
*/
|
||||
public EntityMagicMissile(World world, EntityLivingBase caster, Entity target, float speed, float aimingError,
|
||||
float damageMultiplier){
|
||||
super(world, caster, target, speed, aimingError, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doGravity(){ return false; }
|
||||
|
||||
/**
|
||||
* Creates a projectile pointing in the direction the caster is looking, with the given speed. USE THIS CONSTRUCTOR
|
||||
* FOR NORMAL SPELLS.
|
||||
*/
|
||||
public EntityMagicMissile(World world, EntityLivingBase caster, float speed, float damageMultiplier){
|
||||
super(world, caster, speed, damageMultiplier);
|
||||
}
|
||||
@Override public boolean doDeceleration(){ return false; }
|
||||
|
||||
@Override
|
||||
public void onEntityHit(EntityLivingBase entityHit){
|
||||
@@ -70,23 +49,6 @@ public class EntityMagicMissile extends EntityMagicArrow {
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDamage(){
|
||||
return 4.0d;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doGravity(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean doDeceleration(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void entityInit(){
|
||||
|
||||
}
|
||||
protected void entityInit(){ }
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.projectile.EntityThrowable;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
|
||||
@@ -15,10 +16,7 @@ import net.minecraftforge.fml.common.registry.IEntityAdditionalSpawnData;
|
||||
* <p>
|
||||
* This class purely handles saving of the damage multiplier; EntityThrowable is pretty well suited to my purposes as it
|
||||
* is. Range is done via the velocity when the constructor is called. Caster is already handled by
|
||||
* EntityThrowable.getThrower().
|
||||
*
|
||||
* Note that this class does not implement {@link IEntityAdditionalSpawnData}; subclasses that need to transfer extra
|
||||
* data to the client should implement that interface themselves. See {@link EntityBomb} for an example.
|
||||
* EntityThrowable.getThrower(), though due to a bug in vanilla it has to be synced by this class.
|
||||
*
|
||||
* @since Wizardry 1.0
|
||||
* @author Electroblob
|
||||
@@ -28,70 +26,52 @@ public abstract class EntityMagicProjectile extends EntityThrowable implements I
|
||||
|
||||
public float damageMultiplier = 1.0f;
|
||||
|
||||
/** Creates a new projectile in the given world. */
|
||||
public EntityMagicProjectile(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityMagicProjectile(World world, EntityLivingBase thrower){
|
||||
super(world, thrower);
|
||||
// Initialiser methods
|
||||
|
||||
/** Sets the shooter of the projectile to the given caster, positions the projctile at the given caster's eyes and
|
||||
* aims it in the direction they are looking with the given speed. */
|
||||
public void aim(EntityLivingBase caster, float speed){
|
||||
this.setPosition(caster.posX, caster.posY + (double)caster.getEyeHeight() - 0.1d, caster.posZ);
|
||||
// This is the standard set of parameters for this method, used by snowballs and ender pearls amongst others.
|
||||
this.shoot(caster, caster.rotationPitch, caster.rotationYaw, 0.0f, speed, 1.0f);
|
||||
this.thrower = caster;
|
||||
// Mojang's 'fix' for the projectile-hitting-thrower bug actually made the problem worse, hence the following line.
|
||||
this.ignoreEntity = caster;
|
||||
}
|
||||
|
||||
public EntityMagicProjectile(World world, EntityLivingBase thrower, float damageMultiplier){
|
||||
super(world, thrower);
|
||||
// This is the standard set of parameters for this method, used by snowballs and ender pearls amongst others.
|
||||
this.shoot(thrower, thrower.rotationPitch, thrower.rotationYaw, 0.0f, this.getSpeed(), 1.0f);
|
||||
this.damageMultiplier = damageMultiplier;
|
||||
/** Sets the shooter of the projectile to the given caster, positions the projctile at the given caster's eyes and
|
||||
* aims it at the given target with the given speed. The trajectory will be altered slightly by a random amount
|
||||
* determined by the aimingError parameter. For reference, skeletons set this to 10 on easy, 6 on normal and 2 on hard
|
||||
* difficulty. */
|
||||
public void aim(EntityLivingBase caster, Entity target, float speed, float aimingError){
|
||||
|
||||
this.thrower = caster;
|
||||
// Mojang's 'fix' for the projectile-hitting-thrower bug actually made the problem worse, hence the following line.
|
||||
this.ignoreEntity = thrower;
|
||||
}
|
||||
|
||||
public EntityMagicProjectile(World world, double x, double y, double z){
|
||||
super(world, x, y, z);
|
||||
}
|
||||
this.posY = caster.posY + (double)caster.getEyeHeight() - 0.1d;
|
||||
double dx = target.posX - caster.posX;
|
||||
double dy = !this.hasNoGravity() ? target.getEntityBoundingBox().minY + (double)(target.height / 3.0f) - this.posY
|
||||
: target.getEntityBoundingBox().minY + (double)(target.height / 2.0f) - this.posY;
|
||||
double dz = target.posZ - caster.posZ;
|
||||
double horizontalDistance = (double)MathHelper.sqrt(dx * dx + dz * dz);
|
||||
|
||||
/** This got removed at some point since 1.7.10, but I liked it so I thought I'd add it back in again. */
|
||||
protected float getSpeed(){
|
||||
return 1.5f;
|
||||
}
|
||||
if(horizontalDistance >= 1.0E-7D){
|
||||
|
||||
double dxNormalised = dx / horizontalDistance;
|
||||
double dzNormalised = dz / horizontalDistance;
|
||||
this.setPosition(caster.posX + dxNormalised, this.posY, caster.posZ + dzNormalised);
|
||||
|
||||
/** Sets this projectile's velocity as a normalised vector towards the target. */
|
||||
public void directTowards(Entity target, float velocity){
|
||||
|
||||
double dx = target.posX - this.posX;
|
||||
double dy = target.getEntityBoundingBox().minY + (double)(target.height / 2.0F)
|
||||
- (this.posY + (double)(this.height / 2.0F));
|
||||
double dz = target.posZ - this.posZ;
|
||||
|
||||
this.motionX = dx / this.getDistance(target) * velocity;
|
||||
this.motionY = dy / this.getDistance(target) * velocity;
|
||||
this.motionZ = dz / this.getDistance(target) * velocity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(){
|
||||
// This fixes the client-side projectile-hitting-thrower bug. Comparing with 1.10.2, this was caused by a change
|
||||
// to the line EntityThrowable:215, where a thrower != null check was added. Since the thrower field is not synced,
|
||||
// this fails and the ignoreEntity field is never set, causing the projectile to hit its thrower client-side.
|
||||
// The 'proper' way to fix this is to use IEntityAdditionalSpawnData to sync the thrower field, but I don't really
|
||||
// want to waste packets like that, so, since things worked just fine in 1.10.2 without the thrower != null check,
|
||||
// it makes sense to just duplicate that block of code and remove the offending check.
|
||||
// The only side-effect (and probably why the change was made to vanilla) is that if this entity is summoned
|
||||
// inside a mob using commands, it wouldn't hit that mob. This is so minor that it's not worth sending a packet
|
||||
// for, though it may become more noticeable if spells firing from blocks are added.
|
||||
// TODO: Investigate whether this is still necessary in 1.12
|
||||
// if(this.world.isRemote){
|
||||
//
|
||||
// List<Entity> list = this.world.getEntitiesWithinAABBExcludingEntity(this, this.getEntityBoundingBox().expand(this.motionX, this.motionY, this.motionZ).grow(1.0D));
|
||||
//
|
||||
// for(Entity entity : list){ // Why does vanilla still not use a for-each loop?
|
||||
// if(entity.canBeCollidedWith() && this.ticksExisted < 2 && this.ignoreEntity == null){
|
||||
// this.ignoreEntity = entity;
|
||||
// }
|
||||
// }
|
||||
// // Pretty sure EntityThrowable handles the rest.
|
||||
// }
|
||||
|
||||
super.onUpdate();
|
||||
// Depends on the horizontal distance between the two entities and accounts for bullet drop,
|
||||
// but of course if gravity is ignored this should be 0 since there is no bullet drop.
|
||||
float bulletDropCompensation = !this.hasNoGravity() ? (float)horizontalDistance * 0.2f : 0;
|
||||
this.shoot(dx, dy + (double)bulletDropCompensation, dz, speed, aimingError);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,15 +87,20 @@ public abstract class EntityMagicProjectile extends EntityThrowable implements I
|
||||
}
|
||||
|
||||
@Override
|
||||
// For now, we're only writing when the thrower exists, so subclasses MUST CALL SUPER LAST.
|
||||
// TODO: Figure out whether there's a default value we can write that is never used as an entity id (0? -1? +/-MAX_VALUE?)
|
||||
public void writeSpawnData(ByteBuf data){
|
||||
data.writeInt(this.getThrower().getEntityId());
|
||||
if(this.getThrower() != null) data.writeInt(this.getThrower().getEntityId());
|
||||
}
|
||||
|
||||
@Override
|
||||
// For now, we're only writing when the thrower exists, so subclasses MUST CALL SUPER LAST.
|
||||
public void readSpawnData(ByteBuf data){
|
||||
Entity entity = this.world.getEntityByID(data.readInt());
|
||||
if(entity instanceof EntityLivingBase) this.thrower = (EntityLivingBase)entity;
|
||||
this.ignoreEntity = this.thrower;
|
||||
if(data.isReadable()){
|
||||
Entity entity = this.world.getEntityByID(data.readInt());
|
||||
if(entity instanceof EntityLivingBase) this.thrower = (EntityLivingBase)entity;
|
||||
this.ignoreEntity = this.thrower;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,26 +18,14 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntityPoisonBomb extends EntityBomb {
|
||||
|
||||
public EntityPoisonBomb(World par1World){
|
||||
super(par1World);
|
||||
public EntityPoisonBomb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntityPoisonBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier);
|
||||
}
|
||||
|
||||
public EntityPoisonBomb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
Entity entityHit = rayTrace.entityHit;
|
||||
|
||||
if(entityHit != null){
|
||||
// This is if the poison bomb gets a direct hit
|
||||
|
||||
@@ -18,25 +18,12 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntitySmokeBomb extends EntityBomb {
|
||||
|
||||
public EntitySmokeBomb(World par1World){
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntitySmokeBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier);
|
||||
}
|
||||
|
||||
public EntitySmokeBomb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
public EntitySmokeBomb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
// Particle effect
|
||||
if(world.isRemote){
|
||||
|
||||
@@ -15,32 +15,14 @@ import net.minecraft.world.World;
|
||||
|
||||
public class EntitySpark extends EntityMagicProjectile {
|
||||
|
||||
public EntitySpark(World par1World){
|
||||
super(par1World);
|
||||
public EntitySpark(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntitySpark(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
}
|
||||
|
||||
public EntitySpark(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
/** This is the speed */
|
||||
protected float getSpeed(){
|
||||
return 0.5F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
Entity entityHit = rayTrace.entityHit;
|
||||
|
||||
if(entityHit != null){
|
||||
|
||||
@@ -98,17 +80,13 @@ public class EntitySpark extends EntityMagicProjectile {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of gravity to apply to the thrown entity with each tick.
|
||||
*/
|
||||
protected float getGravityVelocity(){
|
||||
return 0.0F;
|
||||
|
||||
@Override
|
||||
public boolean hasNoGravity(){
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this entity should be rendered as on fire.
|
||||
*/
|
||||
@Override
|
||||
public boolean canRenderOnFire(){
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -7,42 +7,26 @@ import electroblob.wizardry.registry.WizardrySounds;
|
||||
import electroblob.wizardry.util.MagicDamage;
|
||||
import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import electroblob.wizardry.util.WizardryUtilities;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class EntitySparkBomb extends EntityBomb {
|
||||
|
||||
public EntitySparkBomb(World par1World){
|
||||
super(par1World);
|
||||
public EntitySparkBomb(World world){
|
||||
super(world);
|
||||
}
|
||||
|
||||
public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
|
||||
public EntitySparkBomb(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier,
|
||||
float blastMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier, blastMultiplier);
|
||||
}
|
||||
|
||||
public EntitySparkBomb(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult rayTrace){
|
||||
|
||||
this.playSound(SoundEvents.ENTITY_FIREWORK_BLAST_FAR, 0.5f, 0.5f);
|
||||
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
Entity entityHit = rayTrace.entityHit;
|
||||
|
||||
if(entityHit != null){
|
||||
// This is if the spark bomb gets a direct hit
|
||||
@@ -58,15 +42,7 @@ public class EntitySparkBomb extends EntityBomb {
|
||||
|
||||
// Particle effect
|
||||
if(world.isRemote){
|
||||
for(int i = 0; i < 8; i++){
|
||||
double x = this.posX + rand.nextDouble() - 0.5;
|
||||
double y = this.posY + this.height / 2 + rand.nextDouble() - 0.5;
|
||||
double z = this.posZ + rand.nextDouble() - 0.5;
|
||||
ParticleBuilder.create(Type.SPARK).pos(x, y, z).spawn(world);
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, this.posX + rand.nextFloat() - 0.5,
|
||||
this.posY + this.height / 2 + rand.nextFloat() - 0.5, this.posZ + rand.nextFloat() - 0.5, 0, 0,
|
||||
0);
|
||||
}
|
||||
ParticleBuilder.spawnShockParticles(world, posX, posY + height/2, posZ);
|
||||
}
|
||||
|
||||
double seekerRange = 5.0d * blastMultiplier;
|
||||
@@ -102,15 +78,7 @@ public class EntitySparkBomb extends EntityBomb {
|
||||
|
||||
}else{
|
||||
// Particle effect
|
||||
for(int j = 0; j < 8; j++){
|
||||
double x = target.posX + rand.nextFloat() - 0.5;
|
||||
double y = target.getEntityBoundingBox().minY + target.height * rand.nextFloat();
|
||||
double z = target.posZ + rand.nextFloat() - 0.5;
|
||||
ParticleBuilder.create(Type.SPARK).pos(x, y, z).spawn(world);
|
||||
world.spawnParticle(EnumParticleTypes.SMOKE_LARGE, target.posX + rand.nextFloat() - 0.5,
|
||||
target.getEntityBoundingBox().minY + target.height * rand.nextFloat(),
|
||||
target.posZ + rand.nextFloat() - 0.5, 0, 0, 0);
|
||||
}
|
||||
ParticleBuilder.spawnShockParticles(world, target.posX, target.getEntityBoundingBox().minY + target.height/2, target.posZ);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import electroblob.wizardry.util.MagicDamage.DamageType;
|
||||
import electroblob.wizardry.util.ParticleBuilder;
|
||||
import electroblob.wizardry.util.ParticleBuilder.Type;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.init.SoundEvents;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.math.RayTraceResult;
|
||||
@@ -17,26 +16,11 @@ public class EntityThunderbolt extends EntityMagicProjectile {
|
||||
super(par1World);
|
||||
}
|
||||
|
||||
public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase){
|
||||
super(par1World, par2EntityLivingBase);
|
||||
}
|
||||
@Override public boolean hasNoGravity(){ return true; }
|
||||
|
||||
public EntityThunderbolt(World par1World, EntityLivingBase par2EntityLivingBase, float damageMultiplier){
|
||||
super(par1World, par2EntityLivingBase, damageMultiplier);
|
||||
}
|
||||
|
||||
public EntityThunderbolt(World par1World, double par2, double par4, double par6){
|
||||
super(par1World, par2, par4, par6);
|
||||
}
|
||||
|
||||
/** This is the speed */
|
||||
protected float getSpeed(){
|
||||
return 2.5F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called when this EntityThrowable hits a block or entity.
|
||||
*/
|
||||
@Override public boolean canRenderOnFire(){ return false; }
|
||||
|
||||
@Override
|
||||
protected void onImpact(RayTraceResult par1RayTraceResult){
|
||||
|
||||
Entity entityHit = par1RayTraceResult.entityHit;
|
||||
@@ -63,6 +47,7 @@ public class EntityThunderbolt extends EntityMagicProjectile {
|
||||
this.setDead();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(){
|
||||
|
||||
super.onUpdate();
|
||||
@@ -80,18 +65,5 @@ public class EntityThunderbolt extends EntityMagicProjectile {
|
||||
this.setDead();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the amount of gravity to apply to the thrown entity with each tick.
|
||||
*/
|
||||
protected float getGravityVelocity(){
|
||||
return 0.0F;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether this entity should be rendered as on fire.
|
||||
*/
|
||||
public boolean canRenderOnFire(){
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user