Make the bot sleep #320
Replies: 1 comment 1 reply
-
No need for complicated code when this can simply be done with command blocks. Set up a ticking area. Essentially, enter the command /tickingarea add x y z x2 y2 z2 where the coordinates specify the two opposite corners of the area. The resulting area will probably be larger than what you specify as it seems to use whole chunks, so don't be alarmed if the actual coordinates of the area differ from what you entered. Change your game mode to creative (/gamemode c @s) and give yourself a command block (/give @s command_block). You'll also need a comparator and you may want some bedrock to put around this circuit to protect it. Place the first command block. Set the block type to "repeat," condition to "unconditional," and redstone to "always active." Leave "execute on first tick off and set the delay to 102 ticks. The actual code to enter is execute @A ~ ~ ~ testforblock ~ ~-1 ~ bed -1. Run a comparator out of that command block and into another command block. For this block, set block type to "impulse," condition to "unconditional," and redstone to "needs redstone." The command code is time set 95500. Finally, put one more command block on top of that block with block type set to "chain," condition set to "conditional," and redstone set to "always active." The code is weather clear. Surround the circuit with bedrock so no one can mess with it. Run the command /gamerule commandblockoutput false to stop the command blocks from spamming chat. That's it! From the side, your setup should look like o_8 where the o is one command block, the _ is the comparator, and the 8 is the two stacked command blocks. |
Beta Was this translation helpful? Give feedback.
-
I'm trying to make the bot go to sleep when another player on the server starts sleeping,
my only issue right now is that it doesn't go to sleep even when i supply what i assume are correct parameters.
My current code:
runtime_entity_id is defined earlier in the script and is derrived from the start_game packet
Beta Was this translation helpful? Give feedback.
All reactions