• 1

    posted a message on Making a stick give the levitation effect

    You can give the player a stick to use for this with a custom tag like so:

    give @p stick{levitation:1} 1

    Then you can add a custom advancement to a datapack (.json) with any name you want, I chose 'hurt_test.json'. The code is this:

        "criteria": {
            "hurt": {
                "trigger": "minecraft:entity_hurt_player",
                "conditions": {
                    "damage": {
                        "type": {
                            "source_entity": {
                                "equipment": {
                                    "mainhand": {
                                        "item": "minecraft:stick",
                                        "tag": "levitation:1"
        "rewards": {
            "function": "myepicdatapack:hurt_by_stick"

    The code checks if the player has been hurt by any entity (including other players), and checks if that entity was holding a stick with the 'levitation:1' tag. If this is all true it runs the function 'hurt_by_stick' from your datapack. Now you can add some code in that function:

    effect give @s levitation 5 2
    advancement revoke @s only myepicdatapack:hurt_test

    This function (ran when the advancement checking for damage with the stick is dealt) gives the effect for 5 seconds with an amplifier of 2 (can be changed between 0-255) and it removes the testing advancement from the player so that the method can be used again.

    I didn't have time to test all this myself, but everything should work. The only things that I'm uncertain about are the custom tags and the advancement.

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on 1.16.5, trying to make a command involving tags, yet removing a tag is not working?

    Hello! To me everything seems perfect, I even tried it myself and it works flawlessly. So you have these commands in a ticked function or repeating command blocks:

    /execute as @e[tag=NexusTestWaystone,tag=!inZone] at @s if entity @p[distance=..1] run tag @s add inZone
    /execute as @e[tag=NexusTestWaystone,tag=inZone] at @s unless entity @p[distance=..1] run tag @s remove inZone

    This works without problems, maybe you just made a small mistake when using the commands?

    Posted in: Commands, Command Blocks and Functions
  • 1

    posted a message on Draining Item Durability Over Time

    You can store the player's starting armor damage in a score like this:

    /execute store result score @p durability run data get entity @p Inventory[{Slot:102b}].tag.Damage

    Of course, this is damage, not the durability value, but that does not matter for our use. You cannot directly modify the player's NBT (so their inventory), but you can other entities'. We will summon an armor stand holding an iron chestplate like so:

    /summon armor_stand ~ ~ ~ {Tags:["chestplate"],HandItems:[{id:"minecraft:iron_chestplate",Count:1b,tag:{Damage:1}},{}]}

    I gave it a damage value of 1 because then we can modify it (if there is no damage, we can't modify the value). We will now copy the scoreboard value to the damage of the armor stand's iron chestplate like this:

    /execute store result entity @e[tag=chestplate,limit=1] HandItems[0].tag.Damage int 1 run scoreboard players get @p durability

    Finally, we can copy the item from the armor stand to the player like so:

    /item replace entity @s armor.chest from entity @e[tag=chestplate,limit=1] weapon.mainhand

    Using all these commands and a simple command to decrease the durability value, you can do exactly that!

    Posted in: Commands, Command Blocks and Functions
  • To post a comment, please .