Uploaded image for project: 'Minecraft: Java Edition'
  1. Minecraft: Java Edition
  2. MC-215531

The carved pumpkin overlay is rendered in spectator mode

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • None
    • 1.16.5, 21w06a, 21w07a, 21w08a, 21w08b, 21w10a, 21w11a, 21w13a, 21w14a, 21w15a, 21w16a, 21w17a, 21w19a, 21w20a, 1.17 Pre-release 1, 1.17 Pre-release 3, 1.17 Pre-release 4, 1.17 Pre-release 5, 1.17 Release Candidate 1, 1.17 Release Candidate 2, 1.17, 1.17.1 Pre-release 1, 1.17.1 Pre-release 3, 1.17.1 Release Candidate 1, 1.17.1, 21w37a, 21w39a, 21w40a, 21w43a, 1.18, 1.18.1, 22w05a, 1.18.2 Pre-release 1, 1.18.2, 1.19, 1.19.2, 1.19.3
    • Confirmed
    • Spectator
    • Rendering
    • Normal

    Description

      The Bug:

      The carved pumpkin overlay is rendered in spectator mode.

      Steps to Reproduce:

      1. Equip a carved pumpkin on your head by using the command provided below.
        /item replace entity @s armor.head with minecraft:carved_pumpkin
      2. Switch into spectator mode.
      3. Take note as to whether or not the carved pumpkin overlay is rendered in spectator mode.

      Observed Behavior:

      The carved pumpkin overlay is rendered.

      Expected Behavior:

      The carved pumpkin overlay would not be rendered.

      Code Analysis:

      Code analysis by Avoma can be found below.

      The following is based on a decompiled version of Minecraft 1.19.2 using MCP-Reborn.

      net.minecraft.client.gui.Gui.java
      public class Gui extends GuiComponent {
         ...
         public void render(PoseStack poseStack, float v) {
            ...
            if (this.minecraft.options.getCameraType().isFirstPerson()) {
               if (this.minecraft.player.isScoping()) {
                  this.renderSpyglassOverlay(this.scopeScale);
               } else {
                  ...
                  ItemStack itemstack = this.minecraft.player.getInventory().getArmor(3);
                  if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem())) {
                     this.renderTextureOverlay(PUMPKIN_BLUR_LOCATION, 1.0F);
                  }
               }
            }
            ...

      If we look at the above class, we can see that there are two checks that are carried out before allowing the carved pumpkin overlay to render. One of these checks is to see if the player is in first person and the other is to check if the player has a carved pumpkin on their head. If both of these requirements are met, the carved pumpkin overlay is rendered. The game doesn't check if the player is in spectator mode before allowing the carved pumpkin overlay to render, therefore resulting in this problem occurring.

      Fix:

      Simply altering the appropriate existing "if" statement within this piece of code to check if the player is in spectator mode before allowing the carved pumpkin overlay to render will resolve this problem.

      Current "if" statement:
      if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem()))
      Fixed "if" statement:
      if (itemstack.is(Blocks.CARVED_PUMPKIN.asItem()) && !this.minecraft.player.isSpectator())

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              Avoma [Helper] Avoma
              Votes:
              9 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                CHK: