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

Add a way to animate armor models in HumanoidArmorLayer #1541

Merged
merged 5 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
--- a/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java
+++ b/net/minecraft/client/renderer/entity/layers/HumanoidArmorLayer.java
@@ -66,22 +_,28 @@
@@ -54,34 +_,47 @@
float p_117104_,
float p_117105_
) {
- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.CHEST, p_117098_, this.getArmorModel(EquipmentSlot.CHEST));
- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.LEGS, p_117098_, this.getArmorModel(EquipmentSlot.LEGS));
- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.FEET, p_117098_, this.getArmorModel(EquipmentSlot.FEET));
- this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.HEAD, p_117098_, this.getArmorModel(EquipmentSlot.HEAD));
+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.CHEST, p_117098_, this.getArmorModel(EquipmentSlot.CHEST), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_);
+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.LEGS, p_117098_, this.getArmorModel(EquipmentSlot.LEGS), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_);
+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.FEET, p_117098_, this.getArmorModel(EquipmentSlot.FEET), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_);
+ this.renderArmorPiece(p_117096_, p_117097_, p_117099_, EquipmentSlot.HEAD, p_117098_, this.getArmorModel(EquipmentSlot.HEAD), p_117100_, p_117101_, p_117102_, p_117103_, p_117104_, p_117105_);
}

+ /** @deprecated Neo: use {@link #renderArmorPiece(PoseStack, MultiBufferSource, LivingEntity, EquipmentSlot, int, HumanoidModel, float, float, float, float, float, float)} instead. */
+ @Deprecated
private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, T p_117121_, EquipmentSlot p_117122_, int p_117123_, A p_117124_) {
+ this.renderArmorPiece(p_117119_, p_117120_, p_117121_, p_117122_, p_117123_, p_117124_, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F);
+ }
+
+ private void renderArmorPiece(PoseStack p_117119_, MultiBufferSource p_117120_, T p_117121_, EquipmentSlot p_117122_, int p_117123_, A p_117124_, float limbSwing, float limbSwingAmount, float partialTick, float ageInTicks, float netHeadYaw, float headPitch) {
ItemStack itemstack = p_117121_.getItemBySlot(p_117122_);
if (itemstack.getItem() instanceof ArmorItem armoritem) {
if (armoritem.getEquipmentSlot() == p_117122_) {
this.getParentModel().copyPropertiesTo(p_117124_);
this.setPartVisibility(p_117124_, p_117122_);
Expand All @@ -13,6 +35,7 @@
- int j = armormaterial$layer.dyeable() ? i : -1;
- this.renderModel(p_117119_, p_117120_, p_117123_, p_117124_, j, armormaterial$layer.texture(flag));
+ net.neoforged.neoforge.client.extensions.common.IClientItemExtensions extensions = net.neoforged.neoforge.client.extensions.common.IClientItemExtensions.of(itemstack);
+ extensions.setupModelAnimations(p_117121_, itemstack, p_117122_, p_117124_, limbSwing, limbSwingAmount, partialTick, ageInTicks, netHeadYaw, headPitch);
GizmoTheMoonPig marked this conversation as resolved.
Show resolved Hide resolved
+ int fallbackColor = extensions.getDefaultDyeColor(itemstack);
+ for (int layerIdx = 0; layerIdx < armormaterial.layers().size(); layerIdx++) {
+ ArmorMaterial.Layer armormaterial$layer = armormaterial.layers().get(layerIdx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,22 @@ default Model getGenericArmorModel(LivingEntity livingEntity, ItemStack itemStac
return original;
}

/**
* Called when an armor piece is about to be rendered, allowing parts of the model to be animated or changed.
*
* @param itemStack The item stack being worn
* @param livingEntity The entity wearing the armor
* @param equipmentSlot The slot the armor stack is being worn in
* @param model The armor model being rendered
* @param limbSwing The swing position of the entity's walk animation
* @param limbSwingAmount The swing speed of the entity's walk animation
* @param partialTick The partial tick time
* @param ageInTicks The total age of the entity, with partialTick already applied
* @param netHeadYaw The yaw (Y rotation) of the entity's head
* @param headPitch The pitch (X rotation) of the entity's head
*/
default void setupModelAnimations(LivingEntity livingEntity, ItemStack itemStack, EquipmentSlot equipmentSlot, HumanoidModel<?> 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.
* <p>
Expand Down