I am creating a Minecraft game that is similar to the game polytopia, but I am having trouble with the "exploring" feature. The exploring feature basically allows the player to walk around their 1 chunk spawning area, and there is a glass 1 thick floor around the floating chunk, the player can step on the glass, on either side of the chunk. Basically I want to run something like this: execute if entity @a[chunk=[62,-2]. I was thinking about this way because when you forceload a chunk, it forceloads as a 2 number area, like [62, -2], so I want a way to see if the player is inside that chunk. For testing, you can just run say test I created something similar to this but it is very inefficient, I just did, if a player is standing on a certain color glass, it will run the command. I would prefer in game commands inside command blocks rather than datapacks.

Here is the inefficient way I did it: (video)


I did notice something in MCStacker with a "SpawnForced" Option, and I'm thinking that could be helpful

  • 1
    Which edition of Minecraft are you playing?
    – pppery
    May 6, 2023 at 15:32
  • 1
    Minecraft Java 1.19.4. I'll edit my question quick. Sorry for not making that specific! May 6, 2023 at 15:46

2 Answers 2


I stored my x position and my z position as a scoreboard "x", and "z", then I duplicated that scoreboard by setting it to "storeX" and "storeZ", so I can still use "x" and "z" scoreboards, without changing their values in an operation. I created the scoreboard objectives:

/scoreboard objectives add z dummy
/scoreboard objectives add x dummy
/scoreboard objectives add storeZ dummy
/scoreboard objectives add storeX dummy
/scoreboard objectives add Positions dummy
/scoreboard objectives add ChunkZ dummy
/scoreboard objectives add ChunkX dummy
/scoreboard objectives add 16 dummy
/scoreboard players set @a 16 16

Then I ran the commands in a datapack (If somebody wanted to do this without a datapack, just make the scoreboards with the lines above, and put each of these lines below into separate repeating command blocks (except for #comments)):

execute store result score @a z run data get entity @a[limit=1] Pos[2]
execute store result score @a x run data get entity @a[limit=1] Pos[0]
scoreboard players operation @a storeZ = @a z
scoreboard players operation @a storeX = @a x

execute store result score @a ChunkX run scoreboard players operation @a storeX /= @a 16
execute store result score @a ChunkZ run scoreboard players operation @a storeZ /= @a 16

scoreboard objectives setdisplay sidebar Positions

scoreboard players operation X Positions = JKWarrior15 x
scoreboard players operation Z Positions = JKWarrior15 z
scoreboard players operation ChunkX Positions = JKWarrior15 ChunkX
scoreboard players operation ChunkZ Positions = JKWarrior15 ChunkZ

After that, I created an execute if function, where I would run:

/execute if score JKWarrior15 ChunkX matches 62 if score JKWarrior15 ChunkZ matches -2 run say You are in chunk [62,-2]!

and it worked!


to check if a player is standing within a specific chunk, you can use the /execute positioned command with the if entity sub-command to check for players within a specific area. Here's an example command you can try:

/execute positioned 62 0 -2 if entity @a[x=62,y=0,z=-2,dx=15,dy=255,dz=15]

This command checks if there are any players within the chunk at coordinates (62, -2) by using the positioned sub-command to set the command's execution position to the center of the chunk. The if entity sub-command then checks for players within a box of size 16x256x16 (the size of a single chunk) centered at the execution position.

If you want to run a specific command when a player is detected within the chunk, you can add the command to the end of the /execute command, like this:

/execute positioned 62 0 -2 if entity @a[x=62,y=0,z=-2,dx=15,dy=255,dz=15] run say You are in the chunk!

This will make the command block display a message in the chat whenever a player is detected within the chunk.

Regarding the "SpawnForced" option in MCStacker, this is used to forcibly load a chunk into memory regardless of the player's proximity to it. This can be useful for maintaining a certain area, but it's not necessary for your current use case of detecting when a player is within a specific chunk.

  • 4
    except OP asked for Chunk [62 -2] not position 62 -2.
    – Plagiatus
    May 8, 2023 at 9:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .