TransWikia.com

Do command blocks stop working at a certain distance?

Arqade Asked on March 19, 2021

This is regarding minecraft bedrock edition. I am trying to automatically change players to adventure mode when when entering a town and back to survival mode when leaving. I created a function which is executing in a repeating command block. The below commands basically create 2 towns. If player 1 goes into player 2 town it puts them in adventure mode. When player 1 enters their own town it puts them in creative mode. Leaving both towns will put them in survival mode.

#run this one time to create a townMode variable
#scoreboard objectives add townMode dummy 

scoreboard players set @a[scores={townMode=!0}] townMode 0

#town for player 1
scoreboard players set @a[name=player1name, scores={townMode=!1}, x=501, y=62, z=151, dx=49, dy=49, dz=49] townMode 1
scoreboard players set @a[name=!player1name, scores={townMode=!2}, x=501, y=62, z=151, dx=49, dy=49, dz=49] townMode 2

#town for player 2
scoreboard players set @a[name=player2name, scores={townMode=!1}, x=501, y=62, z=93, dx=49, dy=49, dz=49] townMode 1
scoreboard players set @a[name=!player2name, scores={townMode=!2}, x=501, y=62, z=93, dx=49, dy=49, dz=49] townMode 2

gamemode 0 @a[scores={townMode=0},m=!0]
gamemode 1 @a[scores={townMode=1},m=!1]
gamemode 2 @a[scores={townMode=2},m=!2]

Its basically working BUT I noticed that the command block stops executing the commands if I am too far away. If I put the command block in the center of the town it works but if I put it really far away it doesnt seem to trigger consistently. I noticed this after a few hours beating my head against the table. I saw via commandblockoutput the commands stop running if Im too far from the command block. Is there any workaround where I can have the command block far from the villages but still work?

2 Answers

Alas in bedrock command blocks do not stay loaded when you get too far away even if placed in the world spawn area. I tried it experimentally and the commands stop running if I get too far away. I however did find this post which says you can add up to 10 'ticking areas'. This works like a charm in bedrock! Will upvote the answers since the do look like they would work in java edition and you led me in the right direction.

/tickingarea x1 y1 z1 x2 y2 z2 chunkName

Correct answer by George on March 19, 2021

Command blocks follow the same rules as other blocks, in that they will stop running if the chunk they are located in is unloaded.

This question asked something similar. One solution that was suggested there, by @MBraedley:

The chunks surrounding the world spawn are always loaded, so this is the best place to put command blocks that you always want to run. You can change where the world spawn is using the /setworldspawn command.

Answered by Sciborg on March 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP