Jump to content

[1.18.1] Custom blocks do not spawn after breaking them


Wendfrey

Recommended Posts

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
Link to comment
Share on other sites

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.

 

Link to comment
Share on other sites

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.