diff --git a/gradle.properties b/gradle.properties index ef1c0375..7d739a3f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ loader_version_range=[4,) mod_id=sophisticatedbackpacks mod_name=Sophisticated Backpacks mod_license=GNU General Public License v3.0 -mod_version=3.20.24 +mod_version=3.20.25 mod_group_id=sophisticatedbackpacks mod_authors=P3pp3rF1y, Ridanisaurus mod_description=Fancy and functional backpacks. diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackLayerRenderer.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackLayerRenderer.java index 73dea0d9..8c75362b 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackLayerRenderer.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackLayerRenderer.java @@ -34,22 +34,24 @@ public BackpackLayerRenderer(RenderLayerParent entityRendererIn) { } @Override - public void render(PoseStack matrixStack, MultiBufferSource buffer, int packedLight, T entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { + public void render(PoseStack poseStack, MultiBufferSource buffer, int packedLight, T entity, float limbSwing, float limbSwingAmount, float partialTicks, float ageInTicks, float netHeadYaw, float headPitch) { if (entity instanceof AbstractClientPlayer player) { PlayerInventoryProvider.get().getBackpackFromRendered(player).ifPresent(backpackRenderInfo -> { - matrixStack.pushPose(); + poseStack.pushPose(); ItemStack backpack = backpackRenderInfo.getBackpack(); IBackpackModel model = BackpackModelManager.getBackpackModel(backpack.getItem()); EquipmentSlot equipmentSlot = model.getRenderEquipmentSlot(); boolean wearsArmor = (equipmentSlot != EquipmentSlot.CHEST || !backpackRenderInfo.isArmorSlot()) && !player.getInventory().armor.get(equipmentSlot.getIndex()).isEmpty(); - renderBackpack(getParentModel(), player, matrixStack, buffer, packedLight, backpack, wearsArmor, model); - matrixStack.popPose(); + renderBackpack(getParentModel(), player, poseStack, buffer, packedLight, backpack, wearsArmor, model); + poseStack.popPose(); }); } else { + poseStack.pushPose(); ItemStack chestStack = entity.getItemBySlot(EquipmentSlot.CHEST); if (chestStack.getItem() instanceof BackpackItem) { - renderBackpack(getParentModel(), entity, matrixStack, buffer, packedLight, chestStack, false, BackpackModelManager.getBackpackModel(chestStack.getItem())); + renderBackpack(getParentModel(), entity, poseStack, buffer, packedLight, chestStack, false, BackpackModelManager.getBackpackModel(chestStack.getItem())); } + poseStack.popPose(); } } diff --git a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java index 32e1cae0..f761c98a 100644 --- a/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java +++ b/src/main/java/net/p3pp3rf1y/sophisticatedbackpacks/client/render/BackpackModel.java @@ -7,6 +7,7 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.model.AgeableListModel; import net.minecraft.client.model.EntityModel; +import net.minecraft.client.model.HumanoidModel; import net.minecraft.client.model.geom.ModelPart; import net.minecraft.client.model.geom.PartPose; import net.minecraft.client.model.geom.builders.*; @@ -447,13 +448,12 @@ public EquipmentSlot getRenderEquipmentSlot() { } @Override - public > void translateRotateAndScale(M parentModel, LivingEntity livingEntity, PoseStack matrixStack, boolean wearsArmor) { - if (livingEntity.isCrouching()) { - matrixStack.translate(0D, 0.2D, 0D); - matrixStack.mulPose(Axis.XP.rotationDegrees(90F / (float) Math.PI)); + public > void translateRotateAndScale(M parentModel, LivingEntity livingEntity, PoseStack poseStack, boolean wearsArmor) { + if (parentModel instanceof HumanoidModel humanoidModel) { + humanoidModel.body.translateAndRotate(poseStack); } - matrixStack.mulPose(Axis.YP.rotationDegrees(180)); + poseStack.mulPose(Axis.YP.rotationDegrees(180)); float zOffset = wearsArmor ? -0.35f : -0.3f; float yOffset = -0.75f; @@ -462,19 +462,19 @@ public > void translateRotateAn yOffset = CHILD_Y_OFFSET; } - matrixStack.translate(0, yOffset, zOffset); + poseStack.translate(0, yOffset, zOffset); if (livingEntity instanceof Player) { return; } if (livingEntity.isBaby()) { - matrixStack.scale(CHILD_SCALE, CHILD_SCALE, CHILD_SCALE); + poseStack.scale(CHILD_SCALE, CHILD_SCALE, CHILD_SCALE); } if (entityTranslations.containsKey(livingEntity.getType())) { Vec3 translVector = entityTranslations.get(livingEntity.getType()); - matrixStack.translate(translVector.x(), translVector.y(), translVector.z()); + poseStack.translate(translVector.x(), translVector.y(), translVector.z()); } }