How to make in item unusable in crafting?

Basically, is it possible to / how do I make an item (with lore and custom name, etc.) unusable in crafting, so I could use it as a plugin item and the players don’t have the ability to use it as a normal item.

i.e.

  • a super powerful stick that can’t be used to make a shovel.
  • a golden ingot that is used as a currency, and thus can’t be used to make clocks / golden blocks / golden fragments.

(Or, I guess registering a new item/item-id with similar properties to the old one?)

You can use the ItemStack.builder() to create the item, but as far as crating goes, that stuff hasn’t been implemented yet as it rely’s on the Inventory API which is still incomplete.

Isn’t there some kind of craft event that you could listen for?
If so you could simply check the used items for the items you wanna be unusable for crafting and cancel the event I guess.

I don’t see any crafting events in the API as of yet, but there is RecipeRegistry and a few other related Interfaces that I haven’t checked out. Like I stated Recipes rely heavily on the inventory API so I don’t believe any of that stuff works yet

Well then they should get done with it :stuck_out_tongue:
Actually jk, they better do it slow than bad, but that would be really useful if it was implemented.

The problem is primarily one person has been working on it solo. Its kind of his baby from what I can tell. Once it’s all working I think it’s going to end up being pretty powerful. So yeah it’s definitely worth the wait.

Right, I had looked at the API, no crafting event that I saw, as Tren mentioned.

I didn’t know if there was some NBT flag I could use, but alas, as far as I see there is not.

Though perhaps it is possible to register a new ItemType, that extends a Vanilla-Minecraft-ItemType?

Thanks for the help though, @5tingr4y & @TrenTech :wink:

Most NBT related stuff can be indirectly accessed using the Data API. You’ll definitely want to look into all that as it will be key for creating custom items. You’ll just have to work around the lack of crafting for now.

Hi, you can do this :

@Listener
public void onPlayerCraft(ClickInventoryEvent event, @First Player player)
{
	Inventory targetInventory = event.getTargetInventory();
	for (SlotTransaction transaction : event.getTransactions())
	{
		if (targetInventory instanceof ContainerWorkbench)
		{
                //here goes your code
		}
	}
}
1 Like

Interesting… though not “beautiful” it looks like it would work.

Cancelling the “craft” event & then dragging the items back into the player’s inventory, while messaging them “hey you can’t do that!”? I suppose that would work. :stuck_out_tongue:

Thanks!