Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[1.18.1] Spawn Item at a BlockPos


Recommended Posts

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

Link to comment
Share on other sites

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.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.