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

Hi!
It's a stupid question, but i can't find any way.
How can i get the drops of a block?
With BlockState.getDrops() i need a LootTable.Builder context, how can i get that context?

12 minutes ago, Yurim64 said:

With BlockState.getDrops() i need a LootTable.Builder context, how can i get that context?

Have you looked at the LootTable.Builder class to see if it has any useful methods for creating one? That's where I would start! :)

  • Author

Yeah, i saw the code of LootTable and of the Builder, but there is nothing that can help me.
I also found the class LootTables that has some static ResourceLocation of the vanilla loot table files, but i don't know hot to apply them.

One idea is to look for existing usage of the class and replicate it.

The problem is that you can't just "get a block's drops" because it might depend on who's harvesting the block (or for that matter, it might be random!)

What effect are you trying to achieve? (answer from what the player observes happening, not your attempt to code it).

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

The idea is that, the player build a specific structure.
This structure can place and harvest a tree, and place the drops in a chest.

 

So i need the drops of log and leaves, as if the player breaks them.

Edited by Yurim64

3 minutes ago, Yurim64 said:

The idea is that, the player build a specific structure.
This structure can place and harvest a tree, and place the drops in a chest.

 

So i need the drops of log and leaves, as if the player breaks them.

so why do you not use Block#getDrops?

  • Author

Because it needs a LootContext.Builder as parameter;

And if i create one with the ServerWorld as paramenter, it gives me errors as malformed Builder.

2 minutes ago, Yurim64 said:

Because it needs a LootContext.Builder as parameter;

And if i create one with the ServerWorld as paramenter, it gives me errors as malformed Builder.

use the static method Block#getDrops, which requires a BlockState, a world, a position and a TileEntity (nullable)

Edited by Luis_ST

8 minutes ago, Luis_ST said:

use the static method Block#getDrops, which requires a BlockState, a world, a position and a TileEntity (nullable)

BlockState -> yes, ServerWorld -> yes, BlockPos -> No, TileEntity (Nullable) -> yes

check the parameters that you have specified

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.