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.

Featured Replies

Posted

After clicking a block, I'd like to spawn an item at that location... I currently am using `public InteractionResult useOn(UseOnContext context)` and updating some values on a capability and can easily consume said item - however, when I shift (crouch) click I would like to spawn the item back at that location. (currently, requiring the item to exist in hand)

// I can drop item or spawn at location an item - but this is relation to the player (as it's an entity) using one of the following
player.drop(newItem, false);
player.spawnAtLocation(newItem, 0.2F);

However, `drop` creates an animated hand gesture (like player is throwing something on ground - makes sense, but not what I'm looking for) and `spawnAtLocation` is where the player is not where the block clicked is... I've been looking in Level and everywhere to find a similarly named method - I don't see one. What is the best approach to "spawn an item at a clicked block"

 

any guidance of where I should start looking would be appreciated, happy to do the exploring and learning just needing a little nudge in the right direction

Then you need to spawn the ItemEntity manually, after creating the ItemEntiy you need to set the position to the position you want. Then add the ItemEntity to the World via Level#addFreshEntity 

  • Author

Thank you, I've got this implemented now! really appreciate you taking the time to point me in the right direction.

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.