Can anyone help me out with changing the distance a projectile flies? Below is my code for a custom projectile (Copied and changed the snowball base class). Can someone tell me what I need to do, or at least point me in the right direction?
package mods.StaffCraft;
import net.minecraft.block.Block;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.monster.EntityBlaze;
import net.minecraft.entity.projectile.EntityThrowable;
import net.minecraft.util.DamageSource;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
public class EntityFireballProjectile extends EntityThrowable
{
byte dmg = 4;
public EntityFireballProjectile(World par1World)
{
super(par1World);
}
public EntityFireballProjectile(World par1World, EntityLiving par2EntityLiving, double degrees, byte dmg)
{
super(par1World, par2EntityLiving);
this.dmg = dmg;
Vec3 velocity = par1World.getWorldVec3Pool().getVecFromPool(this.motionX, this.motionY, this.motionZ);
velocity.rotateAroundY((float)(degrees*Math.PI/90.0) * (rand.nextFloat() - 0.5F));
this.motionX = velocity.xCoord;
this.motionY = velocity.yCoord;
this.motionZ = velocity.zCoord;
}
public EntityFireballProjectile(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(MovingObjectPosition par1MovingObjectPosition)
{
if (par1MovingObjectPosition.entityHit != null)
{
par1MovingObjectPosition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), dmg);
}
for (int i = 0; i < 8; ++i)
{
//ParticleEffects.spawnParticle("fire", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);
}
if (!this.worldObj.isRemote)
{
this.setDead();
}
}
}
Yep! Thank you! I've been messing around with it though, and I am confused about something. If you increase the Y velocity, shouldn't it go higher, rather than farther? It doesn't seem to change at all when I modify the Z velocity instead of the Y velocity:
Note that the second method here is only used in the EntityThrowable constructor. If you change the motion fields after that, it might not have any effect.
Can anyone help me out with changing the distance a projectile flies? Below is my code for a custom projectile (Copied and changed the snowball base class). Can someone tell me what I need to do, or at least point me in the right direction?
Thanks!
Not really an issue, just wondering if anyone knows why this is.
or increase the speed
Note that the second method here is only used in the EntityThrowable constructor. If you change the motion fields after that, it might not have any effect.