Jump to content

Shooting entity shoots itself


Recommended Posts

Hello, I have this code to spawn a bullet into the world inside the entity of the bullet;

        Random rand = new Random();
        this.shootingEntity = par2EntityLiving;
        this.setSize(0.5F, 0.5F);
        this.setLocationAndAngles(par2EntityLiving.posX, par2EntityLiving.posY + (double)par2EntityLiving.getEyeHeight(), par2EntityLiving.posZ, par2EntityLiving.rotationYaw, par2EntityLiving.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);
        this.yOffset = 0.0F;
        this.motionX = (double)(-MathHelper.sin(this.rotationYaw / ((rand.nextFloat() * 10) + 175.0F) * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionZ = (double)(MathHelper.cos(this.rotationYaw / ((rand.nextFloat() * 10) + 175.0F) * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI));
        this.motionY = (double)(-MathHelper.sin(this.rotationPitch / ((rand.nextFloat() * 10) + 175.0F) * (float)Math.PI));
        this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, 20F * 1.5F, 1.0F);


When this is called upon by the player to shoot the gun it works fine without any problems. However, when this is called upon by a mob to shoot it hits the mob and damages it. The mobs model is ModelBiped so I can't see why this doesn't work.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in

Sign In Now


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.