A mob stealing items from player

Started by Chochlicun on

Topic category: General discussion

Last seen on 20:58, 19. Oct 2023
Joined Oct 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
A mob stealing items from player

Hello, can anyone help me what procedures should be used to make a mob steal items from a player

Last seen on 02:21, 7. May 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Simple method to do it would…
Fri, 10/13/2023 - 15:53

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.

Last seen on 02:21, 7. May 2024
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Oh, also, when you give an…
Fri, 10/13/2023 - 15:55

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.