From 9945aafade1282eeebf71982e44b30317a360467 Mon Sep 17 00:00:00 2001 From: Sara Freimer Date: Sun, 25 Feb 2024 18:35:24 -0600 Subject: [PATCH] Improve rotation speed of the wind generator item --- .../render/item/RenderWindGeneratorItem.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/generators/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java b/src/generators/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java index ba80c6417e6..ec5acf4b85b 100644 --- a/src/generators/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java +++ b/src/generators/java/mekanism/generators/client/render/item/RenderWindGeneratorItem.java @@ -3,6 +3,7 @@ import com.mojang.blaze3d.vertex.PoseStack; import com.mojang.math.Axis; import java.util.List; +import mekanism.client.render.MekanismRenderer; import mekanism.client.render.item.MekanismISTER; import mekanism.generators.client.model.ModelWindGenerator; import mekanism.generators.common.config.MekanismGeneratorsConfig; @@ -17,6 +18,7 @@ public class RenderWindGeneratorItem extends MekanismISTER { public static final RenderWindGeneratorItem RENDERER = new RenderWindGeneratorItem(); + private static final int SPEED = 16; private static float lastTicksUpdated = 0; private static int angle = 0; private ModelWindGenerator windGenerator; @@ -29,21 +31,28 @@ public void onResourceManagerReload(@NotNull ResourceManager resourceManager) { @Override public void renderByItem(@NotNull ItemStack stack, @NotNull ItemDisplayContext displayContext, @NotNull PoseStack matrix, @NotNull MultiBufferSource renderer, int light, int overlayLight) { - float renderPartialTicks = Minecraft.getInstance().getFrameTime(); - if (lastTicksUpdated != renderPartialTicks) { - //Only update the angle if we are in a world and that world is not blacklisted - if (Minecraft.getInstance().level != null) { - List blacklistedDimensions = MekanismGeneratorsConfig.generators.windGenerationDimBlacklist.get(); - if (blacklistedDimensions.isEmpty() || !blacklistedDimensions.contains(Minecraft.getInstance().level.dimension().location())) { - angle = (angle + 2) % 360; + float ticks = Minecraft.getInstance().levelRenderer.getTicks(); + boolean paused = Minecraft.getInstance().isPaused(); + if (!paused) { + if (lastTicksUpdated != ticks) { + //Only update the angle if we are in a world and that world is not blacklisted + if (Minecraft.getInstance().level != null) { + List blacklistedDimensions = MekanismGeneratorsConfig.generators.windGenerationDimBlacklist.get(); + if (blacklistedDimensions.isEmpty() || !blacklistedDimensions.contains(Minecraft.getInstance().level.dimension().location())) { + angle = (angle + SPEED) % 360; + } } + lastTicksUpdated = ticks; } - lastTicksUpdated = renderPartialTicks; + } + float renderAngle = angle; + if (!paused) { + renderAngle = (renderAngle + SPEED * MekanismRenderer.getPartialTick()) % 360; } matrix.pushPose(); matrix.translate(0.5, 0.5, 0.5); matrix.mulPose(Axis.ZP.rotationDegrees(180)); - windGenerator.render(matrix, renderer, angle, light, overlayLight, stack.hasFoil()); + windGenerator.render(matrix, renderer, renderAngle, light, overlayLight, stack.hasFoil()); matrix.popPose(); } } \ No newline at end of file