1.17.x Overwrite vanilla items with custom items

Discussion in 'Spigot Plugin Development' started by TheSotek, Aug 9, 2021.

  1. Hey,

    so I was wondering if there is an easy way to "overwrite" vanilla items.

    For example, I have a custom diamond ItemStack with a description and a custom name.
    Is there a way to completely replace the vanilla diamond with my custom one?
    (crafting, smelting, mining, etc.)

    I don't really know how this would work (if it even does)
     
  2. Well to my knowledge there's no way to do this without changing everything yourself. There might be a library to assist you with doing this, or you could make your own if you have a larger scope than just one item.

    But, as you can see easily from servers like Hypixel Skyblock and Wynncraft, it's definitely possible.
    There's just no quick and easy solution, unless you can find a library that fits your use-case.
     
  3. Of course you can make this possible! Here is what you need to know:
    • for the texture, you can use ItemMeta#setCustomModelData method, but it will require the client to have a texture pack that can read this model data (Custom Model Data tutorial).
    • to check if an item is the custom item you want, use PersistentDataContainer (guide).
    • For the abilities, you need to check if the selected item when a player damaged an entity, for example, you will need to use PersistentDataContainer again (this is how you identify the item) and then do some actions (like cast particles around the mob, etc)
    • you can also change what happens when the item is smelted, crafted and again, identify the item with the PersistentDataContainer.
    • to have a custom recipe, read this article.
    • When a block is mined, check the selected item and then identify it (again).
     
    #3 parpar8090, Aug 9, 2021
    Last edited: Aug 9, 2021
  4. This really isn't what the OP was asking about... They're talking about crafting, mining, and smelting with custom items, rather than custom models and event actions.
     
  5. I changed the reply now.
     
  6. It is possible but you need to think what are all the posible events that you should handle and that depends of the item too, because you can find some items in chests for example, and you should handle not only when crafting, also in those possibilities.

    I thought of:

    ItemPrepareEvent (Change the result when crafting)
    InventoryOpenEvent (Checking somehow if is a chest of loot like the end citys chest)
     
    • Agree Agree x 1
  7. Thank you guys so much!
     
    • Like Like x 1