Started by
Chochlicun
on
Topic category: General discussion
Hello, can anyone help me what procedures should be used to make a mob steal items from a player
Topic category: General discussion
Hello, can anyone help me what procedures should be used to make a mob steal items from a player
Simple method to do it would be to make a procedure triggered when the mob attacks, with a random chance of stealing items. Your entity will need an inventory for this to work, (otherwise it'll just destroy the items), and you'll probably want to make it persistant. (So it doesn't despawn with valuable items if it's out of the player's simulation distance.)
You'd need a random check, (you can use the 'do with 70% chance' procedure template, and probably configure it to a smaller chance), which, if it passes, sets 1 of whatever's in the player's main hand in the entity's inventory, then shrinks the item in the player's main hand for 1. You may also want to check whether or not the entity already has anything in it's inventory, and, if it does, maybe prevent them from stealing more stuff. If you want to randomize this further, you could use a random number to determine which inventory slot it steals from.
Oh, also, when you give an entity an inventory in MCcreator, it automatically makes a GUI that opens when the entity is right clicked. Since you probably don't want this, you can lock your entity's code, and look for an 'override' section that has to do with 'onInteractionResult' somewhere in the code. Delete this entire section, and it'll remove the GUI.