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 ac2c1c8 commit 777749d
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 10 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ org.gradle.daemon=false

mod_id=sophisticatedbackpacks
mod_group_id=sophisticatedbackpacks
mod_version=3.22.1
mod_version=3.22.2
sonar_project_key=sophisticatedbackpacks:SophisticatedBackpacks
github_package_url=https://maven.pkg.github.com/P3pp3rF1y/SophisticatedBackpacks

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
import net.minecraft.client.resources.model.BakedModel;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.client.ForgeHooksClient;
import net.p3pp3rf1y.sophisticatedbackpacks.api.CapabilityBackpackWrapper;

public class BackpackItemStackRenderer extends BlockEntityWithoutLevelRenderer {
Expand All @@ -26,16 +25,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 = ForgeHooksClient.handleCameraTransforms(matrixStack, model, transformType, leftHand);
matrixStack.translate(-0.5D, -0.5D, -0.5D);
RenderType rendertype = ItemBlockRenderTypes.getRenderType(stack, true);
VertexConsumer ivertexbuilder = ItemRenderer.getFoilBufferDirect(buffer, rendertype, true, stack.hasFoil());
itemRenderer.renderModelLists(model, stack, combinedLight, combinedOverlay, matrixStack, ivertexbuilder);
Expand Down

0 comments on commit 777749d

Please sign in to comment.