I am running a forge server and i need to display certain titles to a player when he/she enters an area. I have searched for tutorials on how to do this but to no avail. Help would be greatly appreciated.

Thank you


Solution 1:

Have you tried using command blocks?

You can give your command block using: /give @p minecraft:command_block 1.

This only requires one repeated chain to fulfil.

Basically, we create variables to track:

  • Who is in the area you want your message displayed.
  • Who has the message been played to.

And what we do is:

  • When a player enters our trigger area, we mark them as 'in the area'.
  • Display our title to all players 'in the area' and without a 'executed' mark.
  • Mark all players in the area as executed.
  • When a player leaves the area, remove their 'executed' mark so that the title can execute again.
  • Reset the titles of anyone outside the area and has executed.

1. Create your scoreboards to keep track of players.

/scoreboard objectives add inArea dummy
/scoreboard objectives add executed dummy

2. Create your logic to detect the players.

(This is in a command block chain starting with a repeater command block)

/scoreboard players set @a inArea 0
/scoreboard players set @a[r=__,x=__,y=__,z=__] inArea 1
/scoreboard title reset @a[score_inArea=0,score_executed_min=1] clear
/scoreboard title reset @a[score_inArea=0,score_executed_min=1] reset
/scoreboard players set @a[score_inArea=0] executed 0

If you would like a cuboid area, use:

/scoreboard players set @a inArea 0
/scoreboard players set @a[x=__,y=__,z=__,dx=__,dy=__,dz=__] inArea 1
/scoreboard title reset @a[score_inArea=0,score_executed_min=1] clear
/scoreboard title reset @a[score_inArea=0,score_executed_min=1] reset
/scoreboard players set @a[score_inArea=0] executed 0
  • executed is the scoreboard to store whether or not a player has the title executed on them.
  • inArea is whether or not the player is in the area.

Basically:

  1. Set all players to be marked 'outside' of the area.
  2. Remove executed mark from anyone outside the area so that our trigger can run again.
  3. Mark all players inside the area as 'inside' the area.
  4. Reset titles of those outside of the area and had the title executed on.

Replace the __ with the radius/volume/XYZ of the check area and the origin.

3. Display your title to eligible players.

(In the same command chain as Step 2, only continued. Basically, append these to the end of the chain in Step 2.)

/title @a[score_inArea_min=1,score_executed=0] times <Insert title command args>
/title @a[score_inArea_min=1,score_executed=0] title <Insert title command args>
/title @a[score_inArea_min=1,score_executed=0] subtitle <Insert title command args>
/scoreboard players @a[score_inArea_min=1] executed 1

Basically:

  1. If the player is inside the area and hasn't been executed yet, show him the title.
  2. Mark all players inside the trigger area as executed.

If done right, you should have a repeat command block, followed by a chain of chain command blocks with the commands in the order shown.

Solution 2:

To have a message always display while you are in an area you could do this.

Run this once:

/title @a times 0 3 0

Put this on a looping command block:

/execute @a[x=<x>,y=<y>,z=<z>,dx=<x1>,dy=<y2>,dz=<z2>] ~ ~ ~ title @p title {"text":"In Area"}

But replace x,y,z,x1,y2,z2 with the coordinates you want the area to be and change "In Area" to whatever text you would like to display.