Attempting to create an entity that is only ride-able if tamed (Forge 1.20.1)

Started by PhoelynFabulous on

Topic category: Help with Minecraft modding (Java Edition)

Joined Apr 2026
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Attempting to create an entity that is only ride-able if tamed (Forge 1.20.1)

Hello! I have a Geckolib entity that walks, flies, and can be tamed and ridden. I wanted it to be able to move up when space is held, and goes down when it's let go, and managed it just fine. However, when I did, the creature seemingly lost the ability to freely wander, and since then I've been working on a way to fix it. My current idea for a solution is to make it only ridable when tame - if it doesn't move on its own while tamed, that is much less of a problem to me, albeit sad, so I attempted to settle for this solution when in reality, it has only given me more problems.

Attached are the many pictures of everything I've attempted to make the creature not ridable without being tamed, currently resulting in the game completely crashing.

What I'm looking for is either:

  • The ability to only control the creature if it is tamed
  • The ability to only ride the creature if it is tamed
  • Anything that lets the creature wander freely on its own again
  • Anything that lets the creature wander if it's not tamed

I hope I can find some kind of support on this, as I've tried just about every solution I could find or think up. Please forgive my code if it looks awful - I am a beginner and it is quite cobbled together.

My attempt at making wandering conditional

The code for the flying-up keybind

The AI for the creature

An attempt to making riding only possible if tamed

The full code for the flying keybind. There was a brief period of time where the moth would not fly up and down unless it was tamed. This no longer works.

The specific taming code.

 

Joined Jul 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Try using synced data rather…
Wed, 04/08/2026 - 16:58

Try using synced data rather than nbt. You could make things simpler by using two entities, one is a tamed entity which allows riding and flight, the other is non tamed and walks around etc. You switch the entities on your tame procedure.

Otherwise, use the on entity right clicked trigger. Check if rideable, if not then use returnActionResult fail, that might prevent the player from riding even after right clicking.

Why are you checking client side in the flying procedure?