Posted May 11, 20214 yr 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?
May 11, 20214 yr 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!
May 11, 20214 yr 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.
May 11, 20214 yr 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.
May 11, 20214 yr 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 May 11, 20214 yr by Yurim64
May 11, 20214 yr 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?
May 11, 20214 yr 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.
May 11, 20214 yr 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 May 11, 20214 yr by Luis_ST
May 11, 20214 yr 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.