how do I trigger a /setblock command without a /testfor?

how do I trigger a /setblock command without a /testfor? - Unrecognizable woman holding paw of dog

In my map, the player goes to sleep, then wakes up and finds the windows are changed from regular panes to red ones stained with blood. But if I do /testfor, it will trigger whenever the player passes by, so that is not useful in this circumstance. Is there a way to trigger a command block when you wake up?



Best Answer

You can still use testfor. Here's how it works - set up the device as you would with the testfor, but change the testfor to this command.

/testfor @a {Sleeping:1b}



Pictures about "how do I trigger a /setblock command without a /testfor?"

how do I trigger a /setblock command without a /testfor? - Side view of young woman in hoodie sitting on floor near sofa and playing with obedient brown Labrador while resting during free time
how do I trigger a /setblock command without a /testfor? - Crop hacker silhouette typing on computer keyboard while hacking system
how do I trigger a /setblock command without a /testfor? - Angry Man Is Screaming



What is the command for Setblock in Minecraft?

How to Enter the Command
  • Open the Chat Window. The easiest way to run a command in Minecraft is within the chat window.
  • Type the Command. In this example, we will replace a block with birch planks using the following command: /setblock ~1 ~0 ~1 planks 2.


  • What replaced the Testfor command in Minecraft?

    The /testfor command became obsolete in Minecraft 1.13, and has been replaced by the /execute command*. It will do the same as typing /testfor @e {SelectedItem:{id:"<item>"}} and then putting a comparator to the command block with the command, and then running the command which you wanna run.

    How do you activate a repeating command block?

    To get a repeating command block, players must use the /give command like so: /give @p minecraft:repeating_command_block <amount> . Players can also change a normal command block into a repeating command block by selecting the option in the command block GUI.



    Minecraft Execute Command [1.19] Tutorial




    More answers regarding how do I trigger a /setblock command without a /testfor?

    Answer 2

    You'll either have to trigger something with redstone or use the /testfor command.

    I would recommend testing for the exact block the player stands on when they wake up, as well as the exact time Minecraft warps to when the player wakes up. Realistically that would only occur is if they sleep in the specified bed you want them to.

    Another thing you could try is testing for whether the bed is occupied or not:

     /testforblock <x> <y> <z> minecraft:bed -1 {occupied:true}
    

    Sources: Stack Exchange - This article follows the attribution requirements of Stack Exchange and is licensed under CC BY-SA 3.0.

    Images: Ivan Babydov, Ivan Babydov, Anete Lusina, Andrea Piacquadio