diff --git a/src/main/java/com/glisco/isometricrenders/mixin/RenderTickCounterMixin.java b/src/main/java/com/glisco/isometricrenders/mixin/RenderTickCounterMixin.java new file mode 100644 index 0000000..b4b3a4c --- /dev/null +++ b/src/main/java/com/glisco/isometricrenders/mixin/RenderTickCounterMixin.java @@ -0,0 +1,23 @@ +package com.glisco.isometricrenders.mixin; + +import com.glisco.isometricrenders.property.GlobalProperties; +import com.glisco.isometricrenders.screen.RenderScreen; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.render.RenderTickCounter; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.ModifyVariable; + +@Mixin(RenderTickCounter.Dynamic.class) +public class RenderTickCounterMixin { + + @Shadow private long prevTimeMillis; + + @ModifyVariable(method = "beginRenderTick(JZ)I", index = 1, argsOnly = true, at = @At("HEAD")) + public long test(long value) { + return MinecraftClient.getInstance().currentScreen instanceof RenderScreen rs && rs.remainingAnimationFrames > 0 + ? this.prevTimeMillis + (1000L / GlobalProperties.exportFramerate) : value; + } + +} diff --git a/src/main/java/com/glisco/isometricrenders/property/DefaultPropertyBundle.java b/src/main/java/com/glisco/isometricrenders/property/DefaultPropertyBundle.java index 0c4a2b3..ee4466c 100644 --- a/src/main/java/com/glisco/isometricrenders/property/DefaultPropertyBundle.java +++ b/src/main/java/com/glisco/isometricrenders/property/DefaultPropertyBundle.java @@ -2,6 +2,7 @@ import com.glisco.isometricrenders.render.Renderable; import com.glisco.isometricrenders.screen.IsometricUI; +import com.glisco.isometricrenders.screen.RenderScreen; import com.glisco.isometricrenders.util.ClientRenderCallback; import com.glisco.isometricrenders.util.Translate; import io.wispforest.owo.ui.component.ButtonComponent; @@ -75,10 +76,15 @@ public void applyToViewMatrix(Matrix4fStack modelViewStack) { this.updateAndApplyRotationOffset(modelViewStack); } - public float rotationOffset() { + public float getRotationOffset() { return this.rotationOffset; } + public void setRotationOffset(int offset) { + this.rotationOffset = offset; + this.rotationOffsetUpdated = true; + } + protected void updateAndApplyRotationOffset(Matrix4fStack modelViewStack) { if (rotationSpeed.get() != 0) { if (!this.rotationOffsetUpdated) { diff --git a/src/main/java/com/glisco/isometricrenders/render/DefaultRenderable.java b/src/main/java/com/glisco/isometricrenders/render/DefaultRenderable.java index 0ae4411..29d0d04 100644 --- a/src/main/java/com/glisco/isometricrenders/render/DefaultRenderable.java +++ b/src/main/java/com/glisco/isometricrenders/render/DefaultRenderable.java @@ -51,7 +51,7 @@ protected void withParticleCamera(Consumer action) { Camera camera = MinecraftClient.getInstance().getEntityRenderDispatcher().camera; float previousYaw = camera.getYaw(), previousPitch = camera.getPitch(); - ((CameraInvoker) camera).isometric$setRotation(this.properties().rotation.get() + 180 + this.properties().rotationOffset(), this.properties().slant.get()); + ((CameraInvoker) camera).isometric$setRotation(this.properties().rotation.get() + 180 + this.properties().getRotationOffset(), this.properties().slant.get()); action.accept(camera); ((CameraInvoker) camera).isometric$setRotation(previousYaw, previousPitch); diff --git a/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java b/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java index 92a8109..745ef31 100644 --- a/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java +++ b/src/main/java/com/glisco/isometricrenders/screen/RenderScreen.java @@ -97,7 +97,7 @@ public class RenderScreen extends BaseOwoScreen { private final FlowLayout rightColumn = Containers.verticalFlow(Sizing.fill(100), Sizing.content()); private final List renderedFrames = new ArrayList<>(); - private int remainingAnimationFrames; + public int remainingAnimationFrames; public RenderScreen(Renderable renderable) { this.renderable = renderable; @@ -251,12 +251,17 @@ protected void build(FlowLayout rootComponent) { framerateField.setTextPredicate(s -> s.matches("\\d*")); framerateField.setChangedListener(s -> { if (s.isBlank()) return; - exportFramerate = Integer.parseInt(s); + int rate = Integer.parseInt(s); + if (rate != 0) + exportFramerate = rate; }); try (var builder = IsometricUI.row(rightColumn)) { this.exportAnimationButton = Components.button(Translate.gui("export_animation"), button -> { if (this.memoryGuard.canFit(this.estimateMemoryUsage(exportFrames)) || Screen.hasShiftDown()) { + if (this.renderable.properties() instanceof DefaultPropertyBundle dpb) { + dpb.setRotationOffset(0); + } this.remainingAnimationFrames = exportFrames; this.client.getWindow().setFramerateLimit(Integer.parseInt(framerateField.getText())); diff --git a/src/main/resources/isometric-renders.mixins.json b/src/main/resources/isometric-renders.mixins.json index f7625d9..81487ae 100644 --- a/src/main/resources/isometric-renders.mixins.json +++ b/src/main/resources/isometric-renders.mixins.json @@ -5,11 +5,12 @@ "compatibilityLevel": "JAVA_16", "plugin": "com.glisco.isometricrenders.mixin.IsometricMixinPlugin", "client": [ + "DrawContextMixin", "HandledScreenMixin", "LivingEntityRendererMixin", "MinecraftClientMixin", "ParticleManagerMixin", - "DrawContextMixin", + "RenderTickCounterMixin", "SliderWidgetInvoker", "TextureManagerMixin", "WorldRendererMixin",