From 571eaad900cc153e5fc1bc95487fc2a8232b380b Mon Sep 17 00:00:00 2001 From: BlayTheNinth <1933180+BlayTheNinth@users.noreply.github.com> Date: Sun, 30 Jun 2024 11:55:38 +0200 Subject: [PATCH] fix: Fix auto sieve rendering --- .../entity/AbstractAutoSieveBlockEntity.java | 2 +- .../client/render/RenderUtils.java | 21 ------------------- .../blockentity/AutoHammerRenderer.java | 3 +-- .../render/blockentity/AutoSieveRenderer.java | 18 +++++++++------- 4 files changed, 12 insertions(+), 32 deletions(-) delete mode 100644 shared/src/main/java/net/blay09/mods/excompressum/client/render/RenderUtils.java diff --git a/shared/src/main/java/net/blay09/mods/excompressum/block/entity/AbstractAutoSieveBlockEntity.java b/shared/src/main/java/net/blay09/mods/excompressum/block/entity/AbstractAutoSieveBlockEntity.java index 236c1c7c..ac8ac953 100644 --- a/shared/src/main/java/net/blay09/mods/excompressum/block/entity/AbstractAutoSieveBlockEntity.java +++ b/shared/src/main/java/net/blay09/mods/excompressum/block/entity/AbstractAutoSieveBlockEntity.java @@ -508,7 +508,7 @@ public AbstractContainerMenu createMenu(int windowId, Inventory inventory, Playe } public SieveAnimationType getAnimationType() { - return SieveAnimationType.DEFAULT; + return SieveAnimationType.DEFAULT; // TODO maybe make this based on skin now that mana sieve is gone } public void applyFoodBoost(FoodProperties food) { diff --git a/shared/src/main/java/net/blay09/mods/excompressum/client/render/RenderUtils.java b/shared/src/main/java/net/blay09/mods/excompressum/client/render/RenderUtils.java deleted file mode 100644 index 7d94fa17..00000000 --- a/shared/src/main/java/net/blay09/mods/excompressum/client/render/RenderUtils.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.blay09.mods.excompressum.client.render; - - -import net.minecraft.core.Direction; - -public class RenderUtils { - - /** - * @deprecated use facing.getHorizontalAngle() instead - */ - @Deprecated - public static float getRotationAngle(Direction facing) { - return switch (facing) { - case NORTH -> 0; - case EAST -> -90; - case SOUTH -> 180; - case WEST -> 90; - default -> -90; - }; - } -} diff --git a/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoHammerRenderer.java b/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoHammerRenderer.java index eb60b96b..c3308606 100644 --- a/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoHammerRenderer.java +++ b/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoHammerRenderer.java @@ -3,7 +3,6 @@ import com.mojang.blaze3d.vertex.PoseStack; import net.blay09.mods.excompressum.api.ExNihiloProvider; import net.blay09.mods.excompressum.client.render.BlockRenderUtils; -import net.blay09.mods.excompressum.client.render.RenderUtils; import net.blay09.mods.excompressum.item.ModItems; import net.blay09.mods.excompressum.registry.ExNihilo; import net.blay09.mods.excompressum.block.entity.AutoHammerBlockEntity; @@ -106,7 +105,7 @@ public void render(AutoHammerBlockEntity tileEntity, float partialTicks, PoseSta BlockRenderDispatcher dispatcher = Minecraft.getInstance().getBlockRenderer(); dispatcher.renderSingleBlock(contentState, poseStack, buffers, combinedLight, combinedOverlay); - if (tileEntity.getProgress() > 0f) { // TODO block break not showing on regular hammer? + if (tileEntity.getProgress() > 0f) { int blockDamage = Math.min(9, (int) (tileEntity.getProgress() * 9f)); BlockRenderUtils.renderBlockBreak(contentState, poseStack, buffers, combinedLight, combinedOverlay, blockDamage + 1); } diff --git a/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoSieveRenderer.java b/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoSieveRenderer.java index 8b0976ae..b480e9d1 100644 --- a/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoSieveRenderer.java +++ b/shared/src/main/java/net/blay09/mods/excompressum/client/render/blockentity/AutoSieveRenderer.java @@ -8,7 +8,6 @@ import net.blay09.mods.excompressum.block.HeavySieveBlock; import net.blay09.mods.excompressum.block.ModBlocks; import net.blay09.mods.excompressum.client.ModModels; -import net.blay09.mods.excompressum.client.render.RenderUtils; import net.blay09.mods.excompressum.client.render.model.TinyHumanModel; import net.blay09.mods.excompressum.block.entity.AbstractAutoSieveBlockEntity; import net.blay09.mods.excompressum.utils.StupidUtils; @@ -27,6 +26,7 @@ import net.minecraft.world.level.block.Blocks; import net.minecraft.world.level.block.state.BlockState; import org.joml.AxisAngle4f; +import org.joml.Math; import org.joml.Quaternionf; import org.jetbrains.annotations.Nullable; @@ -66,14 +66,14 @@ public void render(AbstractAutoSieveBlockEntity blockEntity, float partialTicks, poseStack.pushPose(); poseStack.translate(0.5f, 0f, 0.5f); - poseStack.mulPose(new Quaternionf(new AxisAngle4f(RenderUtils.getRotationAngle(blockEntity.getFacing()), 0f, 1f, 0f))); + poseStack.mulPose(blockEntity.getFacing().getRotation()); + poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(-90), 0f, 1f, 0f))); - // TODO human is laying on the sieve // Render the tiny human poseStack.pushPose(); - poseStack.mulPose(new Quaternionf(new AxisAngle4f(90, 0, 1f, 0))); - poseStack.mulPose(new Quaternionf(new AxisAngle4f(180, 1f, 0, 0))); - poseStack.translate(0, -1.2f, 0.25f); + poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(-90), 0f, 0f, 1f))); + poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(90), 0, 1f, 0))); + poseStack.translate(0f, -1.2f, 0.25f); poseStack.scale(0.75f, 0.75f, 0.75f); MinecraftProfileTexture skin = getPlayerSkin(blockEntity.getCustomSkin()); TinyHumanModel playerModel = getPlayerModel(skin); @@ -84,7 +84,7 @@ public void render(AbstractAutoSieveBlockEntity blockEntity, float partialTicks, // Render the glass around player head if underwater if (blockEntity.isWaterlogged()) { poseStack.pushPose(); - poseStack.translate(-0.425f, 0.6f, -0.175f); + poseStack.translate(-0.95f, -0.42f, -0.175f); float glassScale = 0.35f; poseStack.scale(glassScale, glassScale, glassScale); dispatcher.renderSingleBlock(Blocks.GLASS.defaultBlockState(), poseStack, buffer, combinedLight, combinedOverlay); @@ -96,9 +96,11 @@ public void render(AbstractAutoSieveBlockEntity blockEntity, float partialTicks, poseStack.scale(0.5f, 0.5f, 0.5f); poseStack.translate(-0.25f, 0f, -0.5f); + poseStack.mulPose(new Quaternionf(new AxisAngle4f(Math.toRadians(90), 0f, 0f, 1f))); + poseStack.translate(-0.2f, -0.1f, 0f); + // Render the sieve poseStack.pushPose(); - poseStack.translate(0f, 0.01f, 0f); dispatcher.getModelRenderer().tesselateBlock(level, sieveModel, blockEntity.getBlockState(), blockEntity.getBlockPos(), poseStack, buffer.getBuffer(RenderType.solid()), false, random, 0, Integer.MAX_VALUE); poseStack.popPose();