Jump to content

Recommended Posts

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

Posted

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 

  • Like 1

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...

×   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.

Announcements



×
×
  • Create New...

Important Information

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