Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[1.16.1] Rotation of ProjectileItemEntitiy

Featured Replies

Posted

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.