Skip to content

Commit

Permalink
fix: šŸ› Cleaned up backpack stack rendering so that it would be more cā€¦
Browse files Browse the repository at this point in the history
ā€¦ompatible with rendering that does different transformations than the default gui ones
  • Loading branch information
P3pp3rF1y committed Jan 14, 2025
1 parent 39c254c commit 08437b7
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 11 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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.22.3
mod_version=3.22.4
mod_group_id=sophisticatedbackpacks
mod_authors=P3pp3rF1y, Ridanisaurus
mod_description=Fancy and functional backpacks.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.neoforged.neoforge.client.ClientHooks;
import net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.BackpackWrapper;
import net.p3pp3rf1y.sophisticatedbackpacks.backpack.wrapper.IBackpackWrapper;

Expand All @@ -25,16 +24,8 @@ public BackpackItemStackRenderer(BlockEntityRenderDispatcher blockEntityRenderDi

@Override
public void renderByItem(ItemStack stack, ItemDisplayContext transformType, PoseStack matrixStack, MultiBufferSource buffer, int combinedLight, int combinedOverlay) {
//ItemRenderer.render does transformations that would need to be transformed against in complicated way so rather pop the pose here and push the new one with the same transforms
// applied in the correct order with the getModel
matrixStack.popPose();
matrixStack.pushPose();
ItemRenderer itemRenderer = minecraft.getItemRenderer();
BakedModel model = itemRenderer.getModel(stack, null, minecraft.player, 0);

boolean leftHand = minecraft.player != null && minecraft.player.getOffhandItem() == stack;
model = ClientHooks.handleCameraTransforms(matrixStack, model, transformType, leftHand);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
model.getRenderPasses(stack, true).forEach(bakedModel -> bakedModel.getRenderTypes(stack, true).forEach(renderType -> {
VertexConsumer ivertexbuilder = ItemRenderer.getFoilBufferDirect(buffer, renderType, true, stack.hasFoil());
itemRenderer.renderModelLists(bakedModel, stack, combinedLight, combinedOverlay, matrixStack, ivertexbuilder);
Expand All @@ -46,6 +37,5 @@ public void renderByItem(ItemStack stack, ItemDisplayContext transformType, Pose
itemRenderer.renderStatic(displayItem.getItem(), ItemDisplayContext.FIXED, combinedLight, combinedOverlay, matrixStack, buffer, minecraft.level, 0);
});
}));

}
}

0 comments on commit 08437b7

Please sign in to comment.