Jump to content

Recommended Posts

Posted

Hi everyone, I just started to create mods and I would like to ask you something...
Is it possible to create a block that drops itself only when it is broken by a specific item?
If yes, how can I do it?

Posted (edited)

The short answer:

Yes

 

The long answer:

What block and what item? If you want a modded block to only be harvestable by a vanilla item, you will use different methods than if you want a vanilla block to only be harvestable by a modded item. If you want a modded block to be harvested by a modded item, things should be pretty easy.

 

In the case that you have a modded block to be harvested by a modded or non-modded item, I'm not totally sure, but I believe the preferred method is using a loot table. Maybe somebody else knows how to check for the item used to harvest a block in a block's loot table.

There's also methods like canHarvestBlock and onBlockDestroyed in items like ShearsItem.

Or harvestTool in Block.Properties, but I think that would require making a new ToolType if the item in question is not an axe or pickaxe.

 

Edited by skyjay1
  • Like 1
Posted
10 hours ago, skyjay1 said:

The short answer:

Yes

 

The long answer:

What block and what item? If you want a modded block to only be harvestable by a vanilla item, you will use different methods than if you want a vanilla block to only be harvestable by a modded item. If you want a modded block to be harvested by a modded item, things should be pretty easy.

 

In the case that you have a modded block to be harvested by a modded or non-modded item, I'm not totally sure, but I believe the preferred method is using a loot table. Maybe somebody else knows how to check for the item used to harvest a block in a block's loot table.

There's also methods like canHarvestBlock and onBlockDestroyed in items like ShearsItem.

Or harvestTool in Block.Properties, but I think that would require making a new ToolType if the item in question is not an axe or pickaxe.

 

ok, so if I use a modded pickaxe to break a modded block how should I do?

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.