Started by
ГолубьОбычный
on
Topic category: Help with Minecraft modding (Java Edition)
I want to make a mod for a sword that cannot be thrown away, can you tell me how to do this?
Topic category: Help with Minecraft modding (Java Edition)
I want to make a mod for a sword that cannot be thrown away, can you tell me how to do this?
Run a player tick update. Check for item in player inventory, if not in inventory then add to inventory/main hand. Then if item not in inventory check for entity type custom_item and kill it in a 10x10 area around the player. For the chest, it depends on how you get the item in the first place. You can check for item in open gui inventory and then remove it and add it back to the player inventory, but that would mean if the item is found in a chest it would immediately transfer to the inventory. Otherwise to fix this you could make a logic variable that sets to true when the item is first put into the player inventory or put into the main hand.
You could also make it so you save the inventory slot in which the item is held and then place the item back into the exact same slot.