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

Hello!

I'm new at minecraft modding and i'm testing how to create a basic block, and I was able to create it and its BlockItem, but when I break the block it doesn't drop back the item. I also checked the Forge documentation but i can't see anything related to this.

Things I did:

  • Checked that method Block#asItem() returns the ItemBlock
  • Checked if there were a special tag i needed to add and didn't found anything (mineable/pickaxe for example, but only when requiresCorrectToolForDrops is used)
  • Added and removed the block property requiresCorrectToolForDrops
  • Added loot_table in data, copy pasted from cobblestone loot_table. I tested it in my mod folder and adding a minecraft folder. (data/minecraft/loot_table/test_block.json)
  • Checked onDestroyedByPlayer

Creating and registering test_block:

public static RegistryObject<Block> TEST_BLOCK = BLOCKS.register("test_block", new Supplier<Block>() {
  @Override
    public Block get() {
    return new Block(BlockBehaviour.Properties.of(Material.DIRT).strength(0.5f,0.5f).noOcclusion());
  }
});

Creating and registering test_item:

private static RegistryObject<BlockItem> TEST_ITEM = ITEMS.register(
  "test_item", 
  () -> {
    return new BlockItem(TEST_BLOCK.get(), new Item.Properties().tab(CreativeModeTab.TAB_MISC).stacksTo(64));
  }
);

BLOCKS and ITEMS are the DeferredRegister of their respective ForgeRegistries.

I'm using Forge 1.18.1-39.0.9.

And just in case someone asks, i'm testing in survival.

What am I missing?

As an additional question: where do i tell which tier a pìckaxe needs to be for my block to be harvestable?

Edited by Wendfrey
i suck ass writing in english

The drop is controlled by loot tables but you have the wrong location, it should be in data/yourmod/loot_tables/blocks/test_block.json

For the tiers of pickaxe, you use the tag for mineable/pickaxe which you already have and you also add it to the /tags/blocks/needs_diamond_tool.json or whatever level you want.

 

  • Author

Thank you, I can confirm that I am a doofus and forgot to add the folder 'blocks' inside the loot_tables folder.

Also thanks for the 'needs_xxxx_tool' tag!

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.