X

NOTICE

Are you sure you want to report this?

We've split up the commands, scripting and mods, and add ons category! Please be sure you get your thread in the right place.

74

Re-add testfor command

31 Comments

Post a new comment:

Please sign in to leave a comment.

  • 4
    Gametron 13 commented
    Comment actions Permalink

    Omg please vote for this! I hate that they removed the /testfor command.

  • 8
    Robin Rogge commented
    Comment actions Permalink

    This would be a step backwards.
    The testfor command is obsolete in 1.13 and it makes sense for it to be removed.

    Here you can get a very detailed overview about the command functionalities, I would suggest playing around with it a bit.

  • 0
    raity41 commented
    Comment actions Permalink

    I Actually rarely used the /testfor command.

  • 1
    tryashtar commented
    Comment actions Permalink

    You learned how to use it before, you can learn the new way too.

    /testfor was almost entirely useless -- whatever selector you put in it could instead be put in the following command.

  • 0
    Comment actions Permalink

    You can still detect an amount of player (or any entity) without using the /testfor. For example, if you want a redstone block to be placing if there is 6 cows in a radius of 6 blocks, you have to do this :

    just one time : /scoreboard objectives add *whatyouwant* dummy

    Then instead of the /testfor command :

    /tag @e[type=cow,distance=..6,sort=random,limit=1] add choose

    /execute as @e[type=cow,distance=..6] run scoreboard players add @e[tag=choose,type=cow,distance=..6] *whatyouwant* 1

    /execute as @e[type=cow,distance=..6,scores={*whatyouwant*=6}] run setblock X Y Z redstone_block

    /scoreboard players set @e[type=cow,distance=..6,tag=choose] *whatyouwant* 0

    /tag @e[tag=choose] remove choose

    If you want to compact this system, you can use another entity to keep the score, or make it into a function.

  • 0
    Comment actions Permalink

    If you are playing on bedrock edition its easy

    /execute is basically using an entity as a command block. for example

    /execute @e[type=zombie] ~ ~ ~ effect @p[r=1.5] instant_damage 1 100

    the part "/execute @e[type=zombie] ~ ~ ~" means the zombie is the command block in this case.

    ONE MORE EXAMPLE:

    you know how you cant hear /playsound from a distance using the command block?

    use /execute @a ~ ~ ~ playsound <name:string> @a ~ ~ ~

    Why? Because the player is basically the command block, so the player makes the sound.

    Hope this helps!

  • 2
    Comment actions Permalink

    YES! I have so many maps that used things like /testfor. One of the worlds has so many of them... it would take me weeks or even months to go around finding all the command blocks and replacing them with /execute

  • 1
    mike bruens commented
    Comment actions Permalink

    also re-add the testforblock and testforblocks commands. please mojang, why did you remove them

  • 3
    amrtarek ct commented
    Comment actions Permalink

    Want to testfor?
    Use : /execute if
    It's for free
    & asking for /testfor back is pointless cause the new system is better
    I was like you (confused) in the begging & hoped the old system were remained but when I experted it I really like the new system

  • 2
    Comment actions Permalink

    just a great yes, please I don't get the use of execute: an hellish hard command whereas with testfor I just have to /testfor me {Inventory:"Minecraft:arrow",count:1} , just try the same thing with execute! yeah you can't, you can't check if an item is in inventory or not with execute. So no comparator, no on-off. Just bring back testfor!

    Execute doesn't even consider multi tags like id + count

  • 1
    Andre Chen commented
    Comment actions Permalink

    @HeliusEagleclaw

    Try this command:

    execute if entity @s[nbt={Inventory:[{id:"minecraft:string"}]}]

    It probably works even better than the testfor example you gave in your comment given the fact that your command was written with completely incorrect syntax.

    Please don't be lazy. Anyone with a few brain cells could not only learn but master the new syntax in less than 10 seconds. It's literally just 2 words.

  • 1
    Comment actions Permalink

    I would love to see it again

  • 3
    Rick Glatz commented
    Comment actions Permalink

    It's not a matter of laziness or not knowing how the new system is "better".  /testfor returned a count, basically the only way to acquire a count is to jury rig something with scoreboards, which is awful, and not at all useful (and also displays to every player everywhere if an OP user issued  the command which is... pretty likely).  A simple numerical returned value for the target is all that is needed for most things, but it's still needed.  The alternative is only a solution if the question being asked is a true/false.  Still need the underlying numeric information to be found somehow.  I thought I saw some way to do this somewhere but can't find it anywhere now so feel free to correct me with an example of say... how to have the number of villagers within 5 blocks appear on the screen without the use of a scoreboard.

    /testfor @e[type=villager,distance=..5] 

  • 1
    Junmion kun commented
    Comment actions Permalink

    testfor command  is my invis trap

  • 1
    FlashPvPrc commented
    Comment actions Permalink

    they should add it again but not remove the new execute and they should also add returned to be able to select the @e @e returned for example: tp @e [type = armor_stand, name = hello] @e [type = arrow]

  • 2
    emmyg1114 commented
    Comment actions Permalink

    PLSSSSSS it would make my life a lot easyier

  • 0
    vasko vasev commented
    Comment actions Permalink

    what about BLOCKS {mumbles}step backwards

  • 1
    Luticus Pyros commented
    Comment actions Permalink

    This to infinity.  Removing this broke all my command block driven automatic doors in my world!  I'm kinda peeved about it.  Like what was the point of even removing the command?   Could someone maybe provide an alternative working command to test for players within a radius of a command block.  /testfor @p[r=5] was SO easy and simple and WHY would they remove it?!

  • 1
    mrcoffee1026 commented
    Comment actions Permalink

    you could do something like this:

     

    /data get entity @e[type=player,distance=..10,sort=nearest,limit=1]

     

    and then perhaps grab an always available data item and see if it has a value... not as useful as a count or as simple as the testfor, but this would still be doable.  Same with blocks since you can /data get block and then provide the same sort of details to narrow down the block type.  This does not - in any way - excuse the removal of the command, however.

  • 0
    Comment actions Permalink

    I just came from bedrock and noticed that /testfor is gone. The reason this command was helpful was because when you have a repeating command block with /execute something in it, it constantly activates the chain command blocks in front of it. But I only wanted it to activate a command block once. This is impossible in java, but not in bedrock. Using a redstone comparator, you can get just one redstone signal so the commands ahead activate only once. You can't do the same with /execute, only /testfor. Right now I'm trying to replicate that but it is not consistent. That is why testfor should've been kept in the game. Just because something is seemed as useless to you doesn't mean you have to get rid of it. For example, I did /testfor @e[type=item,name=Book] then placed a redstone comparator into a /summon lightning_bolt (coordinates) if you replace the testfor command with a /execute command it won't work. If you switch to chain command blocks it constantly spams lightning bolts.

  • 0
    rioreus12 commented
    Comment actions Permalink

    Certainly, I don't think it was necessary to erase it. However, I often play the bedrock edition, so please consider adding the Java edition execute there.

  • 0
    Andre Chen commented
    Comment actions Permalink

    Rick Glatz

    I'm quite positive that "execute if entity" also returns a count of the number of entities that passed the conditions, nothing else required. In fact, I'd go as far as to say that "execute if entity" can do everything that testfor is purported to be able to do, and then some (given that it can be chained with other subcommands such as store and run).

    The only valid reason I can see for bringing back testfor is that it would be a pain to update creations made pre-1.13 to newer versions, and in my opinion, that's not enough to bring back something outdated and redundant.

  • 0
    seeit360 commented
    Comment actions Permalink

    i’ve never used /testfor but.... i’d love to get “/execute if” on BE

    I’m a developer on BE and would love to see more java parity and with a dumbed down “/execute” command, the complaints about a retired bit of outdated code is a quaint argument. 

  • 0
    mrcoffee1026 commented
    Comment actions Permalink

    No, it does not return a count or any relevant information of any sort.  You can have it wired to a command block or even have it alter the scoreboard (of every single fricking player on the server, making this feature completely useless), but no, getting a simple result number from the use of the command is not possible, which is why testfor is certainly still a need.  Not just for 1.13 scripts but for scripts from any time frame on any server that doesn't want to integrate command blocks or disable the scoreboard for everyone playing just so they can use that.

  • 0
    Bob Joe commented
    Comment actions Permalink

    The thing with the execute command is you don't need to return the count most of the time since you can put both the conditions and a command to run if true in one command. If you really want to count the number of entities that have a specific condition you could create a dummy scoreboard objective, the run:

    /execute as @e[conditions] run scoreboard players add #counter [objective] 1

    note that #counter can be anything as long as it has a # at the start. This creates a scoreboard player without having to summon a real entity. Then to get the result you can run:

    /scoreboard players get #counter [objective]

    this might not be as simple as /testfor, but it has the benefit that it can all be done in 1 tick, and the result can be accessed from anywhere in the world, since you don't need to use a comparator.

    Another thing you could try is

    /execute as @e[conditions] run help (can be any command but /help doesn't affect anything else)

    from a command block at coordinates x y z, then run

    /data get block x y z SuccessCount

    Execute might be a little confusing, but it's a lot more powerful, and there's almost nothing it can't do that testfor can, it just might require a bit of creativity, which is what Minecraft is all about in the first place.

  • 0
    mrcoffee1026 commented
    Comment actions Permalink

    You're basically just reiterating what I said before quite perfectly: there is no simple way to return a count with the execute command: blocks in the world or the scoreboard would have to be utilized... making it completely useless from the command line for the purpose of acquiring a count.   It should be put back to restore this simple, useful, lag free functionality within the scope of single executed command that a person could reasonably type from the console if so desired.  I am not suggesting the removal of the execute command, just stating this simple functionality shouldn't have been removed just because similar inapplicable functionality was added.

  • 0
    Andre Chen commented
    Comment actions Permalink

    mrcoffee1026
    Type in /execute if entity @e and it will give you a count of all loaded entities. It’s that simple. You can put this command in a command block if you want to use comparators for some reason, like how testfor used to work, or you could attach a run command, or you could even store the result in a scoreboard value (which wouldn’t require a scoreboard for every player; I don’t know what you’re talking about). I don’t get why you keep saying “there isn’t a simple way to return a count with execute” when it’s simply not true. Give me whatever problem you seem to be struggling so much with that involves counting entities and I’ll show you how you can do it simply using execute.

  • 0
    mrcoffee1026 commented
    Comment actions Permalink

    I wish that was more clearly documented anywhere, as that is perfect, and really all I wanted the /testfor command back to do... in no answers and in no documentation anywhere did I come across that if you don't actually specify a command to execute, it will just return the count (/execute [what, exactly?] @e[type=cats,distance=..10]).  Had that been clear, anywhere I'd have been saved a lot of inconvenience.  Appreciate the tutorial, thank you much.

  • 0
    Comment actions Permalink

    The new /execute command is very useful, but the /testfor, /testforblock, and /testforblocks had no reason to be removed. They are still useful and having them as seperate commands would help a lot.

  • 0
    qweqwwe commented
    Comment actions Permalink

    PLS ADD AGAIN