1

So I'm playing in Minecraft Java Edition (1.20.4) and made a setup with command blocks that gives items and effects when a player steps on a pressure plate.

Everything works fine when I'm in Creative mode, but when I switch to Survival, it just doesn’t do anything.

I’ve got a repeating command block that checks if a player’s there with /execute if entity @p[...], then chains into a couple others that do /give and /effect. All blocks are always active and some are conditional. But in Survival, the plate clicks, nothing happens. No effects, no items, no errors.

I’ve tried changing @p to @a, even put my name in directly, but still nothing. It’s weird because if I do a simple /say hi command in an impulse block it actually works. It’s just this whole setup that doesn’t. I double-checked I’m opped and that command blocks are enabled. I also tried rebuilding the stuff in a test world but the same issue occured.

Am I missing something?

4
  • Have you set "enable cheats" in your world? Commented Jul 18 at 10:25
  • Oh yes @pinckerman Commented Jul 19 at 0:24
  • 1
    since the command blocks seem to work fine, double check that your entity selectors don't filter by gamemode. off the top of my head i can't remember if gamemode is part of an entity's NBT, but if it is and you have just copy-pasted your NBT data to your selector then it can select on the fact you're in creative. Commented Jul 21 at 8:25
  • To give you an exact and accurate answer to solve your problem, can you specify exactly how your command chain is structured? What are the actual commands in each block? Which ones are conditional? Otherwise, it is more difficult to replicate and guesses have to be made Commented Nov 15 at 9:16

1 Answer 1

1

My best guess is that the problem is not in gamemode (especially if a gamemode or NBT flag wasn't explicitly used), but rather that the command chain only works the first time.

Consider the following chain of commands:

# repeating, unconditional, always active
/execute if entity @p[distance=..2]

# chain, conditional, always active
/effect give @p minecraft:speed infinite

# chain, conditional, always active
/give @p minecraft:diamond_sword

This chain follows the specifications specified in the question - all commands are always active, some are conditional. To make it work with a pressure plate only, you can change the repeating command block to "needs redstone".

In theory, what this should do is give a player that comes close enough to the chain the speed effect forever and a diamond sword, like a kit. It works the first time a player gets close to the chain - giving you a sword and the speed effect. My guess is you first checked it when you were on creative since that's the mode necessary to configure the chain.

Now you try to run it again, presumably on survival. You get close to the chain to the first check is satisfied. However, you already have the speed effect, so the /effect command fails, and never runs the third command. You never get a diamond sword. In other words, the effect command interfered with the give command.

The culprit here is the use of the "conditional" mode of command blocks. This command block mode can be useful in making command chains more efficient, but I encountered more cases where it bugged out command chains than made them more efficient. Therefore I usually stay away from them. As of 1.20 I would also advise to use .mcfunction files since they are much more efficient and less bug-prone.

The case above is especially fixable since execute can naturally be chained inside of its own command:

# impulse, unconditional, needs redstone
execute if entity @p[distance=..2] run effect give @p minecraft:speed infinite

# chain, unconditional, always active
execute if entity @p[distance=..2] run give @p minecraft:diamond_sword

this will work every time the pressure plate is pressed. If you are worried about another player blocking the command chain, you can use a scoreboard tag

# repeating, unconditional, needs redstone
execute if entity @p[distance=..2,tag=!kit] run effect give @p minecraft:speed infinite

# chain, unconditional, always active
execute if entity @p[distance=..2,tag=!kit] run give @p minecraft:diamond_sword

# chain, unconditional, always active
execute if entity @p[distance=..2,tag=!kit] run tag @p add kit

(and this can be even further refined to ensure that it targets the same player without positional weirdness due to each command executing from different positions, etc.)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.