mojira.dev
MC-195499

Players' capes don't render semi-transparent when invisible where appropriate

The Bug:

Players' capes don't render semi-transparent when invisible where appropriate.

This issue can be seen when in spectator mode and looking at invisible players, or being on the same team as them whilst the "seeFriendlyInvisibles" team modification is set to "true".

Steps to Reproduce:

  1. Ensure that you have a cape enabled.

  2. Create a team, join it, and set the "seeFriendlyInvisibles" team modification to "true" by using the commands provided below.

    /team add MC-195499
    /team join MC-195499 @s
    /team modify MC-195499 seeFriendlyInvisibles true
  3. Give yourself the invisibility effect by using the command provided below.

    /effect give @s minecraft:invisibility 100 0
  4. Switch into third person and take note of how your player model is rendered semi-transparent.

  5. Take note as to whether or not players' capes render semi-transparent when invisible where appropriate.

Observed Behavior:

Players' capes aren't rendered at all.

Expected Behavior:

Players' capes would be rendered semi-transparent.

Code Analysis:

The following is based on a decompiled version of Minecraft 26.3 Snapshot 4 using Mojang mappings.

net.minecraft.client.renderer.entity.LivingEntityRenderer.java

boolean isBodyVisible = this.isBodyVisible(state);
boolean forceTransparent = !isBodyVisible && !state.isInvisibleToPlayer;
RenderType renderType = this.getRenderType(state, isBodyVisible, forceTransparent, state.appearsGlowing());
if (renderType != null) {
   int overlayCoords = getOverlayCoords(state, this.getWhiteOverlayProgress(state));
   int baseColor = forceTransparent ? 654311423 : -1;

net.minecraft.client.renderer.entity.layers.CapeLayer.java

if (!state.isInvisible && state.showCape) {

If we look at the above classes, we can see that the body treats being invisible as two separate cases. If the player is invisible and you cannot see them, nothing is drawn. If the player is invisible but you can still see them, which is what the "seeFriendlyInvisibles" team setting in the steps above does, the body is drawn see through instead. That second case is what forceTransparent describes, and the value 654311423 is white at an alpha of 39 out of 255.

The cape has no such distinction. It is skipped whenever the player is invisible, so it disappears completely rather than turning see through.

Making the cape see through also needs the colour above. The cape currently draws itself with the shorter of the two available submitModel methods, and that one always uses a fully opaque colour, so simply changing the drawing mode is not enough on its own.

Fixed Code:

net.minecraft.client.renderer.entity.layers.CapeLayer.java

if (!state.isInvisibleToPlayer && state.showCape) {
   ...
   submitNodeCollector.submitModel(
      this.model,
      state,
      poseStack,
      state.isInvisible
         ? RenderTypes.entityTranslucentCull(skin.cape().texturePath())
         : RenderTypes.entitySolid(skin.cape().texturePath()),
      lightCoords,
      OverlayTexture.NO_OVERLAY,
      state.isInvisible ? 654311423 : -1,
      null,
      state.outlineColor
   );

The above gives the cape the same two cases the body already has.

The check becomes whether the player is invisible to the viewer, rather than whether they are invisible at all, so the cape is drawn in exactly the situations where the body is drawn and is still hidden completely when the player is genuinely hidden.

The drawing mode and the colour then match what the body uses when it draws itself see through. Both are needed, as the colour is what actually makes it see through and the shorter submitModel method cannot pass one.

This change was applied to a modified client and tested against the steps above, and the cape is now drawn semi-transparent along with the rest of the player.

Linked issues

Attachments

Comments 6

Please provide a screenshot of this occurring with your F3 debug screen enabled.

Hi there!

I can confirm in 1.16.1 with standard graphics settings (couldn't get a screenshot, so I'll just type my F3 menu out here):

Minecraft 1.16.1 (1.16.1/vanilla)
87 fps T: inffancy fancy-clouds B: 2
"vanilla" server, 1 tx, 19 rx
C: 979/150544 (s) D: 48, pC: 000, pU: 00, aB: 12
E: 5/13, B: 0
P: 701. T: 13
Client Chunk Cache: 3969, 3249
minecraft:overworld FC: 0

(skipping the part with coordinates, tell me if you need them)

Java: 1.8.0_51 64bit
Mem: 53% 1121/2048MB
Allocated: 96% 1984MB

CPU: 12x AMD Ryzen 5 2600X Six-Core Processor

Display: 1920x1080 (ATI Technologies Inc.)
Radeon RX 570 Series
4.6.13596 Compatibility Profile Context 20.5.1 27.20.1017.1011

I could also confirm on Fast and Fabulous graphics modes.

Attached screenshot just in case its still needed.

Can confirm this behavior in 21w43a. I'd like to request ownership of this ticket since the current reporter has been inactive for over a year.

This ticket relates to MC-240011.

Avoma

(Unassigned)

Confirmed

Player, Rendering

1.16.1, 1.17.1, 21w43a, 1.18, 1.18.1, , 1.21.3, 1.21.4, 25w08a, 1.21.7, 26.3

Retrieved