Posted August 29, 20205 yr Hello, I have a little problem concerning my ProjectileItemEntity. I made a new Item overriding the onItemRightClick method, where a new Entity should be spawned and shooted like a snowball, but at the current stage the Entity always flys in the same direction. The flying itself works perfectly, only the direction is wrong. Here is my code for the item: @Override public ActionResult<ItemStack> onItemRightClick(World worldIn, PlayerEntity playerIn, Hand handIn) { ItemStack stack = playerIn.getHeldItem(handIn); Vector3d look = playerIn.getLookVec(); HeartEntity heart = new HeartEntity(1.0D,1.0D,1.0D,worldIn); heart.setPosition(playerIn.lastTickPosX + look.x , playerIn.lastTickPosY + look.y + 1, playerIn.lastTickPosZ + look.z); Vector3d vec3d = heart.getMotion(); double d0 = heart.getPosX() + vec3d.x; double d1 = heart.getPosY() + vec3d.y; double d2 = heart.getPosZ() + vec3d.z; worldIn.addParticle(ParticleTypes.HEART, d0 - vec3d.x * 0.25D, d1 - vec3d.y * 0.25D, d2 - vec3d.z * 0.25D, vec3d.x, vec3d.y, vec3d.z); heart.setShooter(playerIn); heart.shoot(heart.getPosX(), heart.getPosY(), heart.getPosZ(), playerIn.rotationYaw, playerIn.rotationPitch); if (!worldIn.isRemote) { worldIn.addEntity(heart); if(!playerIn.isCreative()) { stack.shrink(1); } } worldIn.playSound(playerIn, new BlockPos(playerIn.getPositionVec()), SoundEvents.ENTITY_SNOWBALL_THROW, SoundCategory.PLAYERS,1.0f,1.0f); return new ActionResult<ItemStack>(ActionResultType.SUCCESS, stack); } I hope that somebody can help me and thank you in advance.
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.