Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.21.4] Fix IClientItemExtensions#renderHelmetOverlay never being called #1837

Merged
merged 12 commits into from
Jan 14, 2025
17 changes: 17 additions & 0 deletions patches/net/minecraft/client/gui/Gui.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,23 @@
}

private void renderCameraOverlays(GuiGraphics p_316735_, DeltaTracker p_348538_) {
@@ -236,8 +_,14 @@
for (EquipmentSlot equipmentslot : EquipmentSlot.values()) {
ItemStack itemstack = this.minecraft.player.getItemBySlot(equipmentslot);
Equippable equippable = itemstack.get(DataComponents.EQUIPPABLE);
- if (equippable != null && equippable.slot() == equipmentslot && equippable.cameraOverlay().isPresent()) {
- this.renderTextureOverlay(p_316735_, equippable.cameraOverlay().get().withPath(p_380782_ -> "textures/" + p_380782_ + ".png"), 1.0F);
+ if (equippable != null && equippable.slot() == equipmentslot) {
+ if (equippable.cameraOverlay().isPresent()) {
+ this.renderTextureOverlay(p_316735_, equippable.cameraOverlay().get().withPath(p_380782_ -> "textures/" + p_380782_ + ".png"), 1.0F);
+ }
+
+ if (equipmentslot == EquipmentSlot.HEAD) {
IThundxr marked this conversation as resolved.
Show resolved Hide resolved
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack).renderFirstPersonOverlay(itemstack, this.minecraft.player, p_316735_, p_348538_);
+ }
}
}
}
@@ -289,8 +_,12 @@
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
package net.neoforged.neoforge.client.extensions.common;

import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.DeltaTracker;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.model.HumanoidModel;
import net.minecraft.client.model.Model;
import net.minecraft.client.player.LocalPlayer;
Expand All @@ -23,6 +25,7 @@
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.component.DyedItemColor;
import net.minecraft.world.item.equipment.Equippable;
import net.neoforged.fml.LogicalSide;
import net.neoforged.neoforge.client.ClientHooks;
import net.neoforged.neoforge.client.IArmPoseTransformer;
Expand Down Expand Up @@ -142,17 +145,18 @@ default Model getGenericArmorModel(ItemStack itemStack, EquipmentClientInfo.Laye
default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, Model model, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) {}

/**
* Called when the client starts rendering the HUD, and is wearing this item in the helmet slot.
* Called when the client starts rendering the HUD, and is wearing this item in the head equipment slot.
* <p>
* This is where pumpkins would render their overlay.
* <p>
* Note: Only use this if {@link Equippable#cameraOverlay()} doesn't suit your use case
*
* @param stack The item stack
* @param player The player entity
* @param width The viewport width
* @param height Viewport height
* @param partialTick Partial tick time, useful for interpolation
* @param stack The item stack
* @param player The player entity
* @param guiGraphics The gui graphics
* @param deltaTracker The delta tracker
*/
default void renderHelmetOverlay(ItemStack stack, Player player, int width, int height, float partialTick) {}
default void renderFirstPersonOverlay(ItemStack stack, Player player, GuiGraphics guiGraphics, DeltaTracker deltaTracker) {}

/**
* {@return Whether the item should bob when rendered in the world as an entity}
Expand Down
Loading