how can i limit to how many mobs can be tamed

Started by Snow256 on

Topic category: Help with Minecraft modding (Java Edition)

Joined Jan 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
how can i limit to how many mobs can be tamed

Good morning, good afternoon, or good evening! Does anyone know how I could create a limit for tamed mobs in my mod? I want the player to be able to tame only 5 mobs, and this should apply only to mobs from my mod, not those from the vanilla game.

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Create a player persistent…
Fri, 09/01/2023 - 21:58

Create a player persistent number variable then

The global trigger: Entity is tamed.

if event/target entity is subtype of (your mob)

  if source entity is subtype of player:

    if get Global: (variable name) > 5

      cancel event

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
event/target entity in this…
Fri, 09/01/2023 - 22:00

event/target entity in this case would be the mob that got tamed. Or instead of event/target entity is subtype of (your mob) you could make an entity tag for tamable mobs in your mod then do:

replace the "if event/target entity is subtype of (your mob)" with:

if is event/target entity tagged in entity tags as (your entity tag.)

Joined Mar 2020
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Forgot to mention: after if…
Fri, 09/01/2023 - 22:01

Forgot to mention:

after if get Global: (variable name) > 5

         else:

           set Global: (variable name) to Get global: (variable name) + 1