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

As the title says I need a way to get drops from a block that the player has just mined. How to do that? I have seen that getDrops exists but I don't know how to use it or if it is the right solution for this problem. Ideally, it should apply enchants that player has that affect drops (eg. Silk Touch or Fortune) automatically. Any help would be appreciated.

3 hours ago, Mislo_ said:

Ideally, it should apply enchants that player has that affect drops (eg. Silk Touch or Fortune) automatically.

GlobalLootModifiers are most likely the solution you're looking for. You are not required to actually modify the drops if you're only interested in knowing what dropped.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author
3 hours ago, diesieben07 said:

What is your goal? What effect do you want to achieve?

I am making an enchant (for tools) that will put drops from a block directly into a player's inventory. If the inventory is full I just drop items on player's coordinates.

56 minutes ago, Draco18s said:

GlobalLootModifiers are most likely the solution you're looking for.

I have stumbled upon that once but it looks complicated. If it is the best solution I will study it thoroughly and make use of it.

  • Author
11 hours ago, diesieben07 said:

There is no simple way to do this. If you look at PlayerInteractionManager#destroyBlock you'll see that there isn't really any hook to influence the spawning of drops. Block#playerDestroy will eventually be called and simply spawn the drops into the world. You can in theory detect EntityJoinWorldEvent of the ItemEntities, but you don't really have a way to detect whether these are drops of a block mined with a tool that has your enchantment.

So using GlobalLootModifiers would be the best solution. Thanks for making that clear. I would probably spend a few more hours trying to find a different solution. Thanks for help.

6 hours ago, diesieben07 said:

They only allow you to modify what is dropped, not capture what will be dropped or change what is done with the drops.

While I haven't checked, I do believe that the player is part of the LootParameters, so the entire generated drops could be inserted into the player's inventory, and then cleared so nothing actually drops.

Not what the modifiers were intended for, but it might work.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

*puts up a sign: here there be dragons, woe unto thee who venture here*

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.