2

I've added a creative region to my survival world and when players enter/exit that region, I want to display a title and subtitle like so:

Home base title displayed.

This is easy enough to do with the title command and a command block, but I'm having trouble getting the title to only display for players entering/exiting the area.

Currently, I'm trying to chain command blocks to accomplish this task, but I'm not against crafting a function for it, as that's the end goal anyways (though I need the command block way first because my behavior pack isn't ready yet). The setup is currently:

# Block 1 (Repeat, Unconditional, Always Active)
tag @a[r=64] add "home"

# Block 2 (Chain, Conditional, Always Active)
gamemode creative @a[r=70,tag="home"]

# Block 3 (Chain, Conditional, Always Active)
tag @a[r=70,tag="home"] add "home-title"

# Block 4 (Chain, Conditional, Always Active)
title @a[r=70,tag="home-title"] subtitle "This is a safe space."

# Block 5 (Chain, Conditional, Always Active)
title @a[r=70,tag="home-title"] title "Home Base"

There are three other command blocks that are responsible for the exit process, all of which are set to:

  • Repeat
  • Unconditional
  • Always Active

Their commands are:

# Block 1
tag @a[rm=65] remove "home"

# Block 2
tag @a[rm=65] remove "home-title"

# Block 3
gamemode survival @a[rm=65]

My thought process was that for players that already have the home tag, the remaining blocks wouldn't execute, however this is not a true statement, and in hindsight, it never could've been since all remaining blocks impact all players within a 64 block radius.


How can I adjust my setup to ensure only players that are entering/exiting the area will see the title/subtitle with command blocks?

Bonus: Can it be done in a single function?

2
+100

I am slightly confused as to what you're asking, but I think your issue is that you don't want:

tag @a[r=64] add "home"

to return a success if they already have home. If so, simply replace this command with:

execute @a[r=64,tag=!home] tag @s add "home"
1
  • This wasn't exactly what I needed, but it helped me get there! I'll be awarding a bounty to your answer as soon as it's eligible! Jun 20 at 15:33
2

@Penguin's answer helped me arrive at the answer I needed so go upvote their answer!


I had a few issues with my setup. The first was that I was adding the home-title tag before displaying the title, so all users always had the home-title tag. Even with @Penguin's addition of the not operator ! to my logic chain, all users were still seeing the title.

I had to change the order of command execution, in addition to adding the not operator in order for it to work:

#Block 1 (Repeat, Unconditional, Always Active)
tag @a[r=64,tag=!"home"] add "home"

#Block 2 (Chain, Conditional, Always Active)
gamemode creative @a[r=75,tag="home"]

#Block 3 (Chain, Conditional, Always Active)
title @a[r=75,tag=!"home-title"] subtitle "This is a safe space."

#Block 4 (Chain, Conditional, Always Active)
title @a[r=75,tag=!"home-title"] title "Home Base"

#Block 5 (Chain, Conditional, Always Active)
tag @a[r=75,tag="home"] add "home-title"

With this setup only the players entering the area will see the title, while the players already in the area won't.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.