Started by
kios3A
on
Topic category: Advanced modding
I want to make a mob that when it spawn selects an item from a special loot table and if the player is holding that item, they will become aggressive and attack them for that item. I have the detecting part and the loot table part I'm just having trouble with the "randomly choose an item" part. Can anyone help me?
It seems I also need help with getting them to attack you when you hold the item
Instead of using loot tables, try using procedures. When the entity spawns in, set a variable to a random number from 1 to however many items you want it to chose from. Then, have an if statement checking if that varible is 1, another checking if it is 2, and so on. You can use this to set an item, for example, if it is 1, it sets a varible to a wool block. Then, another procedure checks if the player is holding the block in that varible, (for this example, wool) and if they are, check for your entity nearby. If it finds it, despawn it, and spawn in a new entity at the same place, that tries to kill the player. Let me know if you need more help or images on how to do this.