mojira.dev
MC-120083

Players still earn advancements in spectator mode

The Bug

A player can still earn advancements in spectator mode, and they are still broadcast to the server. You can test this by going into spectator mode, and /giving yourself an elytra.

Steps to Reproduce

  • Revoke all advancements from yourself.

    /advancement revoke @s everything
  • Switch into spectator mode and give yourself a lava bucket.

    /give @s minecraft:lava_bucket
  • Take note as to whether or not you are granted the "Hot Stuff" advancement.

Observed Behavior

Players are able to earn advancements whilst in spectator mode.

Expected Behavior

Players would not be able to earn advancements whilst in spectator mode.

Code analysis

Code analysis by @unknown can be found on this comment.

Linked issues

Attachments

Comments 32

Can confirm for MC 1.12.1.

I've reproduced inventory advancements (e.g. get a lava bucket) and location advancements (e.g. find a nether fortress). I could not reproduce "enter block" advancements (e.g. enter an end gateway). Starting to breed animals then entering spectator mode also provides the advancement.

Recipes are also unlocked when their advancement is triggered.

I could not reproduce "enter block" advancements (e.g. enter an end gateway).

@unknown check MC-46421.

Alright, just now I did a more thorough check to see which advancement triggers can be activated by players in spectator mode. I did this by creating an advancement with one criteria, a single trigger of each name with no additional conditions (unless they were required (recipe_unlocked)). The results:
Can be triggered by spectators:

  • bred_animals (breed, then switch gamemodes)

  • changed_dimension (by teleporting across)

  • cured_zombie_villager (feed, then switch gamemodes)

  • effects_changed

  • entity_hurt_player (via /kill)

  • inventory_changed

  • levitation

  • location

  • player_hurt_entity (ignite TNT, then switch gamemodes)

  • player_killed_entity

  • recipe_unlocked

  • nether_travel (enter portal, switch gamemodes, teleport across)

  • summoned_entity (ender dragon)

  • tick

Cannot be triggered by spectators, either because the action is impossible (such as taming an animal) or it simply doesn't trigger (such as entering a block):

  • brewed_potion

  • construct_beacon

  • consume_item

  • enchanted_item

  • enter_block

  • entity_killed_player

  • impossible 😉

  • item_durability_changed

  • placed_block

  • slept_in_bed

  • tame_animal

  • used_ender_eye

  • used_totem

  • villager_trade

Might want to put that this issue relates to MC-46421, because if that is fixed, then it will be affected by this bug.

22 more comments

Can confirm in 1.18.2.

Can confirm in 1.19.

Can confirm in 1.19.2.

Correct fix would IMO be adding a predicate to the existing advancements for survival/adventure mode, rather than hard coding a check for spectator mode; as advancements are often used by datapacks as an event system to trigger functions based on player actions.

Kyiiel

(Unassigned)

Confirmed

Platform

Normal

Advancements

advancement, gamemode

Minecraft 1.12, Minecraft 1.12.1, Minecraft 1.12.2, Minecraft 17w45b, Minecraft 17w46a, ..., 1.20.2, 23w45a, 1.20.4, 1.21, 1.21.4

Retrieved