Skip to content

Instantly share code, notes, and snippets.

View eggohito's full-sized avatar
🥚
egg.

eggohito eggohito

🥚
egg.
  • 22:18 (UTC +08:00)
View GitHub Profile

💡 The variables used are reset after, so you'll need to set them again if you wish to make it persist. 💡


Initial setup

To determine which entity initiated the pickpocket, you'll need to add the pickpocket.actor tag to the entity via the /tag command. Afterwards, you can execute the pickpocket:this function using the /function command as the entity you wish to pickpocket from.


Taking a specific amount of items

Resource bars cannot have fully dynamic max values, at least not yet. This means that you would need to modify the power JSON file just to adjust the max value, which is quite a hassle, especially in an environment where you want it to be configurable in-game easily.

Luckily, we can copy the value of a resource to a score holder in a scoreboard objective, and vice versa. Mix this with being able to do math operations in scoreboard, you can now have a resource with a pseudo-dynamic max value.

How?

First, we would need to create two scoreboard objectives: one for storing the current value of the resource, and one for indicating the max value of the resource. In this example, we'll be naming the scoreboard objectives resource.cur and resource.max respectively