I am trying to make a "script" to stop people from killing cats in my Minecraft server (please don't ask why). My idea is that I want when you tame a cat, a diamond is added to the player's inventory. I tried to use "if entity" but it hasn't worked. Any ideas?

I tried using a scoreboard, expected when the scoreboard was updated, a "/give" command would run and give the current entity a diamond.

This is my code:

one time:

/scoreboard objectives add cat health


/if scoreboard cat [health=0] give @s diamond
  • 1
    I appreciate you are trying to save cats.
    – pinckerman
    Jan 6, 2023 at 18:11
  • 3
    Possible duplicate of How can I make animals unkillable?. Let's cut out the XY problem and do the right thing.
    – pppery
    Jan 6, 2023 at 23:49
  • 1
    @pppery But we don't know if it's a freedom the OP wants to retain but just be vindictive about. And that approach also won't deal with the fact that the main thing the OP is asking for is a way to award taming cats. VTLO.
    – Joachim
    Jan 7, 2023 at 9:02
  • for others wondering how to do this you can do it with a custom advancments datapack. advancements.thedestruc7i0n.ca Jan 8, 2023 at 23:29
  • @Samstercraft that, with a bit more detail, should be an answer, not a comment.
    – Plagiatus
    Feb 3, 2023 at 12:05

2 Answers 2


You can make the animals invulnerable by doing something to the effect of:

/execute as @e[type=cat,distance=..10] run data merge entity @e[limit=1,sort=nearest] {Invulnerable:1b}

This makes any nearby cat unkillable. The distance check isnt necessary, but limits it only to nearby cats rather than any in loaded chunks.

As for giving a diamond when tamed, perhaps you could do something to the effect of:

execute at @e[type=cat,nbt={InLove:600},tag=!gavediamond] run give @a[distance=..6] diamond

the above command gives players near a cat that was just "bred" a diamond. If you want this to only apply the first time, also do:

execute as @e[type=cat,nbt={InLove:600}] run tag @s add gavediamond

Also note that @a targets all players near the cat, so depending on your needs, you may wish to use @p instead, which will target the nearest player. This unfortunately results in the possibility that the diamond may not be given to the one who actually tamed it (thought it almost always will be). Guaranteeing a correct targeting of the player that bred the cat would require use of scoreboards.


The best way to detect whether a player tamed a cat is to use a custom advancement in a data pack. In this case, you're looking for the minecraft:tame_animal trigger, specifying that you're looking for a cat specifically.

Then you can grant a reward function for finishing the advancement, revoking the advancement to make it reusable and giving the player the diamond.

There are various advancement generator websites, one of the best ones imo is https://misode.github.io/advancement/.
If you need an advancement in version 1.16 and below, you can use https://advancements.thedestruc7i0n.ca/, instead.


    "criteria": {
        "tame_cat": {
            "trigger": "minecraft:tame_animal",
            "conditions": {
                "entity": {
                    "type": "minecraft:cat"
    "rewards": {
        "function": "foo:tame_cat"


advancement revoke @s only foo:tame_cat
give @s diamond

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .