mojira.dev
MC-96553

Book score fail on half slabs

Player using book to 'cast' click on a score command targeting themselves does not work on half slabs. More correctly updating score with book fails between elevation of [email protected]@.56 (y@=full number in the y axis).
Have tested this bug as far back as the chain and repeat command blocks were added and always fails.

Below are commands to replicate:
Book:

/give @p written_book 1 0 {pages:["[\"\",{\"text\":\"Bug testing \",\"color\":\"dark_blue\",\"bold\":true},{\"text\":\"\n\",\"color\":\"none\",\"bold\":false},{\"text\":\"Test \\\"Click Cast\\\" below on half slabs. \",\"color\":\"dark_green\"},{\"text\":\"\n\",\"color\":\"none\"},{\"text\":\"Click Cast\",\"color\":\"light_purple\",\"clickEvent\":{\"action\":\"run_command\",\"value\":\"/scoreboard players set @p[score_mana_min=2,r=0] CAST 1\"},\"hoverEvent\":{\"action\":\"show_text\",\"value\":{\"text\":\"\",\"extra\":[{\"text\":\"expect text \\\"Cast test successful.\\\"\",\"color\":\"red\"}]}}}]"],title:Halfslab Book Bug Test,author:RCvie}

Objectives:

/scoreboard objectives add mana dummy
/scoreboard objectives add CAST dummy

Mana score:

/scoreboard players set @p mana 100
/scoreboard objectives setdisplay sidebar mana

Command Block chain on repeat:

/execute @a[score_mana_min=2] ~ ~ ~ /scoreboard players remove @p[score_CAST_min=1,r=0] mana 2
/execute @a[score_CAST_min=1] ~ ~ ~ /say @p Cast test successful.
/scoreboard players set @a[score_CAST_min=1] CAST 0

Linked issues

Comments 2

Duplicate of MC-13526.

As a side-note, you'll find issues regardless. When the player runs a command via a clickEvent in a book (and from /tellraw), they are running the command as if they have typed it in the chat themselves. This means they are subject to standard chat limits, being a 100-character limit, required "/" to run commands, and most importantly the requirement of being OP'd to run OP-only commands (being /scoreboard).

You should use a command like /trigger instead, which allows non-OP's to use the book and also circumvents your issue as it can only target the player running /trigger, and thus no radius issues are present.

You should also not be using /execute in that manner. Firstly, you should only use it when the sender or origin needs to be changed. Since /scoreboard has a target selector, you should use that target selector instead. You can have multiple score parameters if they're checking different objectives.

Secondly, you should not mix an executor of @a with a nested @p. @a is the only selector that can target dead players (as long as radius is not defined). If a player dies, the /execute command will still cause them to run /scoreboard, but they will target the nearest-living player to their body instead of themselves. r=0 is only a band-aid fix because it will still target players that are standing at the same location.

The fix is to use similar selectors and sender bias. If c=1 is used (in situations where player bias does not apply, which does happen to be with /scoreboard), the entity running the command will always target themselves so long as they match the other parameters. Use @a as the executor and @a[c=1] as the nested selector, or @e[type=Player] as the executor and @p as the nested selector. r=0 is not needed. For entities, player bias can be circumvented by removing players from selection (@e[type=!Player] with @e[type=!Player,c=1]).

The nested selector fix is not needed though since /execute can be removed entirely:

/scoreboard players remove @a[score_mana_min=2,score_CAST_min=1] mana 2

Pete Frisky

(Unassigned)

Unconfirmed

Minecraft 16w05a

Retrieved