Posted September 30, 201411 yr Hey guys, I need some help with my entity. I created a a gun which shoots my own entity extends from entityThrowable, but in fact it spawns in my own Player. I already tried a few stuff but nothing worked good, I tried to spown it somewhere out of my character, but then it isn't in the middl of the screen. Do you have any Idea what I can do to fix the problem? public EntityBullet(World world, EntityLivingBase entity, float damage) { super(world, entity); this.thrower = entity; this.setSize(0.25F, 0.25F); this.setLocationAndAngles(entity.posX, entity.posY + (double)entity.getEyeHeight(), entity.posZ, entity.rotationYaw, entity.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; float f = 0.4F; this.motionX = (double)(-MathHelper.sin(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); this.motionZ = (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * MathHelper.cos(this.rotationPitch / 180.0F * (float)Math.PI) * f); this.motionY = (double)(-MathHelper.sin((this.rotationPitch + this.func_70183_g()) / 180.0F * (float)Math.PI) * f); this.setThrowableHeading(this.motionX, this.motionY, this.motionZ, this.func_70182_d(), 1.0F); } @Override protected void entityInit() { } @Override public void readEntityFromNBT(NBTTagCompound p_70037_1_) { } @Override public void writeEntityToNBT(NBTTagCompound p_70014_1_) { } @Override protected void onImpact(MovingObjectPosition mop) { if(mop.entityHit instanceof EntityPlayerMP){ if(mop.entityHit != null && !(mop.entityHit instanceof EntityPlayerMP)){ mop.entityHit.attackEntityFrom(DamageSourceAdvGuns.causeBulletDamage(this, getThrower()), 10F); System.out.println(mop.entityHit); }else{ } setDead(); }else{ System.out.println("Player"); } } public float getGravityVelocity(){ return 0; } } Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
September 30, 201411 yr Let the super constructor do the positioning for you, and just set the damage; this will at least get the bullet not hitting yourself. If it still doesn't look right, you can try your hand again at the positioning. http://i.imgur.com/NdrFdld.png[/img]
September 30, 201411 yr Author Do you mean the float damage in the Constructor? Ialready set the Damage in the onImpact Method, so I dontknow what you exactly mean Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
September 30, 201411 yr Then why do you have a float parameter in your constructor? Just use the super constructor: public EntityBullet(World world, EntityLivingBase entity) { super(world, entity); // done, nothing else here } http://i.imgur.com/NdrFdld.png[/img]
September 30, 201411 yr Author Omg it works, thank you Creator of Extra Shoes Watch out, I'm total jerk, and I'll troll anybody if it feels like its necessary. Pls report me then
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.