How to prevent 'normal inventory consumption' (crafting, brewing) of special items

Please understand first and foremost, the problem here is for a custom-plugin I am making for my own server, which is spongevanilla, will never let anyone else have it, and NEVER will be forge and have to worry about countless number of unimiaginable mods in case there is no generic solution, so targeting specific vanilla behavior only is sufficient.

The special items: I am going to be generating a variety of special rare drops from time to time, which will have display-name and key lore data so as to prevent players from merely renaming things. Some will be frequently produced like ie a sugar item renamed as Salt, and stackable, and others will be uniquely distinctly rare and have a uuid as part of their lore, such as an orange dye called Amber I might go custom-data route even to hide some of the information in the future, I’m still working on it…
I want these items for just two purposes, to either sell directly to the server , or to horde and treasure as valuable assets for show and worth purposes.

Challange: Prevent the item from being used as its base item it is derived from, particularly for crafting. I will be avoiding blockitems as special drops, but things like renamed dyes can still be consumed coloring wool on a crafting space, or renamed ghast tears used in potions. I think I can get around eating edibles or placing decoractives just fine, but things that are consumed via crafting and brewing, I want to prevent.

A solution the comes to mind is listening to inventory events for the player filling one of the slots with a special item (identified by a key lore value or custom data presence) and cancel it, (hopefully) returning it back to the inventory slot it was stored in. For vanilla, this means 2x2 crafting bench, 3x3 crafting bench, potion slots, and furnace fuel and target slots (in case of cumbustable items, or repurposed ores). And outright denial of transfer to hopper slots to prevent transfer into such devices.

  1. Is there an easier solution I’ve overlooked
  2. How would I go about determining if something has been transferred (dragged-over, shift-clicked, drag-dropped) into a slot that belongs to a crafting surface?
1 Like

I see your point, but what happens, if for some mystical reason, you decide to add a mod? I doubt that you will, as you seem pretty set in vanilla, but being able to handle the general case is usually a good thing

Would defintley suggest that. UUIDs in lore feels kind of hacky

  1. There are probably some events specifically associated with what you want to do (though I don’t know what ones)
  2. There is a click event, but I forget what it is called (something like InventoryEvent.Click)

Just listen to the event and check the inventory type, the event is ClickInventoryEvent:

I see your point, but what happens, if for some mystical reason, you decide to add a mod? I doubt that you will, as you seem pretty set in vanilla, but being able to handle the general case is usually a good thing

Of course there is benefit to the general case, but with many such things Sponge, often the answer is in the form of "While in the vanilla server where there is a discrete existing set of things to pick from and code we have to remember that forge is used, there are infinite ways that a mod could add a new thing and there is no way to predetermine that thing is present - otherwise, if we could know the list in advance of every possible inventory screen with a crafting space, then sure, it would be doable with a few lines of code, but since we tend to think about Forge first, we must assume that your question is being asked about a forge server plugin, and thus, cant even propose an approach." so pre-accepting that is the way it is for forgemods, I take it off the table.
In my particular case, it would have to be a hell of a mystical reason, because A) the purpose of this plugin system is to add a little variety into the game with imagination for vanilla clients B) My server is really my wife’s minecraft server, and it lives on in her name where cancer denied her the same ability – she wanted a server for vanilla clients only, but full of whatever fun I can manage to add to it via code, within a set of “I want this, I don’t want that” guidenlines, such that it would be a good first-server for a lot of noob players who are venturing out to join mulitplayer servers and may not even really know how to play the game yet.