Making a Tamed Entity Sit and Follow by Right-Clicking (Like Vanilla Wolves and Cats) (2024.4) *No Coding Needed*

Started by Don't-talk-to-me on

Topic category: User side tutorials

Joined Sep 2019
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Making a Tamed Entity Sit and Follow by Right-Clicking (Like Vanilla Wolves and Cats) (2024.4) *No Coding Needed*

I know tutorials on this topic already exist. However, this tutorial is meant to be concise (so you do not have to search old comment sections), does not use coding, and does not need you to use 2 different entities. This tutorial only needs 1 entity! Figuring this out took some trial and error, but it works for me. And I hope it will work for you.

This tutorial assumes you have some basic Mcreator knowledge already.

You will need: a custom attribute, a right-click procedure, a procedure to insert into the entity's AI, a procedure to apply slowness or custom modifier, and an animation procedure (optional).

  1. Attribute

    Create an attribute and categorize all your affected mobs into this. 

     

    I used attributes so that I did not have to replicate this process using the "subtype" block for every affected entity. It's easier to categorize them. If all of this works without attributes, so be it. However, it is what I used and it works regardless.

  2. Right-Click Procedure

    Global Trigger: Player Right-Clicks on Entity

    if : Does [Event Entity] have attribute [your attribute] AND is [Event Entity] tamed

    do:    if: Get [Event Entity] custom logic NBT tag "Sitting" = false

             do: Set [Event Entity] Custom Logic NBT tag "Sitting to true

             else: Set [Event Entity] Custom Logic NBT tag "Sitting" to false

  3. Procedure to Insert into Entity's AI

    (No Trigger)

    Return logic: not Get [Event Entity] custom logic NBT tag "Sitting"

    You must insert this procedure into your entity's "Follow owner" task for both the Additional Start and Continue conditions. Your entity must have the "Follow Owner" task. If this is not put into the "Follow owner" AI task, then the entity will still teleport to the player.

    You only need to make this procedure once, but it must be inserted into every affected entity's "Follow owner" task.

  4. Procedure to Apply Slowness

    Global Trigger: Entity Tick Update

    if: Is [Event Entity] tamed = true AND Does [Event Entity] have attribute {Your attribute}

    do:   if: Get [Event Entity] custom logic NBT tag "Sitting" = true

            do: add potion effect [Slowness/Yours] with level [your choice, but 7 slowness works] for [99999999] ticks ambient [true] particles [false] to [Event Entity]

            else: Remove specific potion effect [Slowness/Your Choice] from [Event Entity]

     

    The purpose of this is to prevent the entity from moving around once it is instructed to stop following the owner. You have 2 options. You can either use slowness with no particles or you can create your own potion effect that changes the affected entity's speed modifier to -100. The advantage of making your own is that you have the option to disable the effect from rendering in the inventory and HUD. Why does this matter? Because 3rd party mods such as Toro Health can detect what status effects an entity has. However, when I tested this, a potion effect that is not allowed to render in the inventory and HUD does not appear on the 3rd party health-detecting mods. Therefore, it will look like the mob is genuinely sitting. [Take this with a grain of salt though, as I only tested this with Toro Health, and this info can someday become irrelevant as the 3rd party mods update.]

  5. Animations (optional)

    Your entity must already have a sit animation made! This procedure also requires Geckolib! You may be able to improve this on your own, but it works for now. You need 1 of these per affected entity, since attributes do not work here.

    Make sure your sitting animation is set on loop! It will only play once if it is not! This must be fixed in Blockbench!

    Global Trigger: Entity Tick Update

    if: is [Event Entity] subtype {your entity}

    do:  if: Get [Event Entity] custom logic NBT tag "Sitting" = true

           do: if entity element {your entity} is [Event Entity] then play animation {your animation}

           else: if entity element {your entity} is [Event Entity] then stop current procedure triggered animation

 

 

That's all. As you update your mod, you will need to add the new affected mobs to the attribute, insert the same AI altering procedure into the "Follow Owner" task of the new affected mobs, and create a new if/do statement for the animations. Pretty simple to maintain.

If there is some issue, let me know. I hope I typed everything correctly and I hope this works for you. :)

Joined Aug 2023
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Thanks for the tutorial.
Thu, 01/02/2025 - 15:06

Thanks for the tutorial.