Skip to content

Commit

Permalink
fix: Fix auto hammer rotation and content offset
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jul 2, 2024
1 parent c1a40b5 commit 231500c
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,29 +68,34 @@ public void render(AutoHammerBlockEntity tileEntity, float partialTicks, PoseSta
// TODO processed block is too far in the ground
// TODO rotate the hammer, not the handle
poseStack.pushPose();
poseStack.translate(-0.5f, -0.05f, 0f);
poseStack.scale(0.5f, 0.5f, 0.5f);
poseStack.pushPose();
poseStack.translate(-0.7f, -0.3f, 0f);
poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(Math.sin(tileEntity.hammerAngle) * 30), 0, 0, 1f)));
poseStack.translate(-0.4f, 0.2f, 0f);
itemRenderer.renderStatic(hammerItemStack, ItemDisplayContext.FIXED, combinedLight, combinedOverlay, poseStack, buffers, level, 0);
poseStack.popPose();

ItemStack firstHammer = tileEntity.getUpgradeStack(0);
if (!firstHammer.isEmpty()) {
poseStack.pushPose();
poseStack.translate(-0.7f, -0.3f, 0f);
poseStack.translate(0f, 0.1f, 0.33f);
poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(10f), 0f, 1, 0)));
poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(Math.sin(tileEntity.hammerAngle - 8f) * 30), 0, 0, 1f)));
poseStack.translate(-0.4f, 0.2f, 0f);
itemRenderer.renderStatic(firstHammer, ItemDisplayContext.FIXED, combinedLight, combinedOverlay, poseStack, buffers, level, 0);
poseStack.popPose();
}

ItemStack secondHammer = tileEntity.getUpgradeStack(1);
if (!secondHammer.isEmpty()) {
poseStack.pushPose();
poseStack.translate(-0.7f, -0.3f, 0f);
poseStack.translate(0f, 0.1f, -0.33f);
poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(-10), 0f, 1f, 0)));
poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(Math.sin(tileEntity.hammerAngle + 8f) * 30), 0, 0, 1f)));
poseStack.translate(-0.4f, 0.2f, 0f);
itemRenderer.renderStatic(secondHammer, ItemDisplayContext.FIXED, combinedLight, combinedOverlay, poseStack, buffers, level, 0);
poseStack.popPose();
}
Expand All @@ -102,7 +107,7 @@ public void render(AutoHammerBlockEntity tileEntity, float partialTicks, PoseSta
BlockState contentState = StupidUtils.getStateFromItemStack(currentStack);
if (!contentState.isAir()) {
poseStack.pushPose();
poseStack.translate(-0.4f, -0.04f, -0.2);
poseStack.translate(-0.4625f, -0.04f, -0.2);
poseStack.scale(0.4f, 0.4f, 0.4f);
BlockRenderDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer();
dispatcher.renderSingleBlock(contentState, poseStack, buffers, combinedLight, combinedOverlay);
Expand Down

0 comments on commit 231500c

Please sign in to comment.