How can I receive a success output signal from command block on a fill clock?

How can I receive a success output signal from command block on a fill clock? - Inscription on concrete floor in street

I have a setup like this:

enter image description here

In which the yellow command blocks are a standard 20Hz /fill clock, and the blue is a command such as, for example:

/spreadplayers ~ ~ 10 20 false @p[r=5]

My problem, which has cropped up for me quite a few times, is that I want to get some kind of redstone pulse or output when the blue command block succeeds. The obvious solution is a comparator, but that does not work for this as the command executes once and then fails on the next tick, resetting its successcount before the comparator can detect it.

Ideally this output detection should also be pretty fast, although it doesn't have to work at the same frequency as the fill clock. The solution needs to actually be testing for if the command succeeded.

I have tried some things with /blockdata and /testforblock, but no success as of yet.

Edit: Again, the solution needs to actually test for the block succeeding. It cannot just test for, say, the players location, because the command block will not always do something that can be tested for. Imagine that instead it is a /say, relative /fill, or /clear item command.



Best Answer

  • /execute @p[rm=6] ~ ~ ~ /say The command worked
  • /execute @p[r=5] ~ ~ ~ /say The command did not work

(both after the /spreadplayers command). The only problem with that is that it will still act as if the command didn't work if a player gets positioned inside the 5 Blocks radius.

EDIT: It is now completely possible with the CommandStat Data Tag:

/blockdataCommand Block Coordinates{CommandStats:{SuccessCountName:"Fake Player Name / Entity / whatever you're gonna use",SuccessCountObjective:"Scoreboard Objective Name"}}

Basically, you can make the SuccessCount output to a scoreboard. See the video below for more info!

.

EDIT 2: Maybe I should mention that you can then do some sort of execute on the entity if it has a score of at least 1. Also, you should set the score back to 0 at the end of every tick (/cycle of the clock).




Pictures about "How can I receive a success output signal from command block on a fill clock?"

How can I receive a success output signal from command block on a fill clock? - Radio telescope under bright starry sky
How can I receive a success output signal from command block on a fill clock? - Radio telescope against sky with stars
How can I receive a success output signal from command block on a fill clock? - From below of aged metal clock tower located in city center with high towers



How do you use the command clock?

Set the command block somewhere and add redstone repeaters and make sure to time the repeaters to somewhere around 29-30 seconds (if it's not that accurate) and you can just activate a single repeater by right-clicking a lever fast 2 times at the command block.



Episode 2 | How to Make a Super Fast Command Block Clock (1.8.9+)




More answers regarding how can I receive a success output signal from command block on a fill clock?

Answer 2

Dummy Objective Workaround

  • Make a dummy objective, let's call it isNotSpread
  • Hook a command block to the clock that sets it to 1 for @p[r=5]
  • /testfor players with score_isNotSpread_min=1
  • Comparator that into two command blocks to /spreadplayers players with score_isNotSpread_min=1 and reset their isNotSpread objective to 0.

Since the score is not set to 0 before a comparator detects it at 1, this will detect

I'm not too sure, but I believe most of Sethbling's works use this or a similar method.

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

Images: David Underland, Igor Mashkov, Igor Mashkov, Samson Katt