Skip to content

Commit

Permalink
fix: Fix printer inside not rotating with block
Browse files Browse the repository at this point in the history
  • Loading branch information
BlayTheNinth committed Jan 1, 2024
1 parent aeaa518 commit 857a5bf
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.mojang.authlib.minecraft.MinecraftProfileTexture;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.math.Axis;
import net.blay09.mods.forbiddensmoothies.block.CustomBlockStateProperties;
import net.blay09.mods.forbiddensmoothies.block.entity.PrinterBlockEntity;
import net.blay09.mods.forbiddensmoothies.client.ModModels;
Expand All @@ -15,11 +16,13 @@
import net.minecraft.client.renderer.blockentity.BlockEntityRenderer;
import net.minecraft.client.renderer.blockentity.BlockEntityRendererProvider;
import net.minecraft.client.resources.DefaultPlayerSkin;
import net.minecraft.core.Direction;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.RandomSource;
import net.minecraft.world.item.ItemDisplayContext;
import net.minecraft.world.item.ItemStack;
import net.minecraft.world.item.Items;
import net.minecraft.world.level.block.state.properties.BlockStateProperties;
import org.jetbrains.annotations.Nullable;
import org.joml.AxisAngle4f;
import org.joml.Quaternionf;
Expand Down Expand Up @@ -50,6 +53,12 @@ public void render(PrinterBlockEntity blockEntity, float partialTicks, PoseStack
return;
}

poseStack.pushPose();
final var facing = state.hasProperty(BlockStateProperties.HORIZONTAL_FACING) ? state.getValue(BlockStateProperties.HORIZONTAL_FACING) : Direction.NORTH;
poseStack.translate(0.5f, 0f, 0.5f);
poseStack.mulPose(Axis.YN.rotationDegrees(facing.toYRot() + 180f));
poseStack.translate(-0.5f, 0f, -0.5f);

final var dispatcher = Minecraft.getInstance().getBlockRenderer();
poseStack.pushPose();
poseStack.translate(-0.05f, 0.01f, 0.1f);
Expand Down Expand Up @@ -97,6 +106,8 @@ public void render(PrinterBlockEntity blockEntity, float partialTicks, PoseStack
poseStack.popPose();

playerModel.renderItemInHand(poseStack, buffer, LightTexture.FULL_BLOCK, combinedOverlay, level);

poseStack.popPose();
}

private Optional<MinecraftProfileTexture> getPlayerSkin(@Nullable GameProfile gameProfile) {
Expand Down

0 comments on commit 857a5bf

Please sign in to comment.