Skip to content

Commit

Permalink
chore: clean up sulfur render code
Browse files Browse the repository at this point in the history
  • Loading branch information
klikli-dev committed Dec 29, 2022
1 parent a2a226b commit 5c68ffa
Showing 1 changed file with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,11 @@ public void renderLabel(ItemStack sulfurStack, ItemTransforms.TransformType pTra

BakedModel labelModel = itemRenderer.getModel(labelStack, null, null, 0);

pPoseStack.pushPose();

//now apply the transform to the label to make it look right in-world -> because below we render with gui transform which would mess it up
labelModel = labelModel.applyTransform(pTransformType, pPoseStack, isLeftHand(pTransformType));
//despite this returning a model (self in fact) it actually modifies the pose stack, hence the pushPose above!
labelModel.applyTransform(pTransformType, pPoseStack, isLeftHand(pTransformType));

pPoseStack.pushPose();

Expand All @@ -91,6 +94,8 @@ public void renderLabel(ItemStack sulfurStack, ItemTransforms.TransformType pTra
//note: if we reset to 3d item light here it ignores it above and renders dark .. idk why

pPoseStack.popPose();

pPoseStack.popPose();
}

public void renderContainedItem(ItemStack sulfurStack, ItemTransforms.TransformType pTransformType, PoseStack pPoseStack, MultiBufferSource pBuffer, int pPackedLight, int pPackedOverlay) {
Expand All @@ -100,9 +105,14 @@ public void renderContainedItem(ItemStack sulfurStack, ItemTransforms.TransformT
var containedStack = AlchemicalSulfurItem.getSourceStack(sulfurStack);
if (!containedStack.isEmpty()) {
BakedModel containedModel = itemRenderer.getModel(containedStack, null, null, 0);

BakedModel labelModel = itemRenderer.getModel(labelStack, null, null, 0);
pPoseStack.pushPose();
//TODO this
//not sure why we don't have to apply transform here. Somehow label carries over, because if we do not call label our rendering is off
//containedModel = containedModel.applyTransform(pTransformType, pPoseStack, isLeftHand(pTransformType));

//now apply the transform to the contained item to make it look right in-world -> because below we render with gui transform which would mess it up
//despite this returning a model (self in fact) it actually modifies the pose stack, hence the pushPose above!
labelModel.applyTransform(pTransformType, pPoseStack, isLeftHand(pTransformType)); //reuse the label transform to simulate flat items even if the contained item is 3d

pPoseStack.pushPose();

Expand All @@ -119,6 +129,8 @@ public void renderContainedItem(ItemStack sulfurStack, ItemTransforms.TransformT
//note: if we reset to 3d item light here it ignores it above and renders dark .. idk why

pPoseStack.popPose();

pPoseStack.popPose();
}
}
}

0 comments on commit 5c68ffa

Please sign in to comment.