diff --git a/gradle.properties b/gradle.properties index 84c9821..f73eaee 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,7 +9,7 @@ org.gradle.parallel = true loader_version = 0.14.11 # Mod Properties - mod_version = 1.0.0 + mod_version = 1.0.1 maven_group = net.krlite archives_base_name = bounced-1.19 diff --git a/src/main/java/net/krlite/bounced/Bounced.java b/src/main/java/net/krlite/bounced/Bounced.java index ba6f1e9..260c37b 100644 --- a/src/main/java/net/krlite/bounced/Bounced.java +++ b/src/main/java/net/krlite/bounced/Bounced.java @@ -1,7 +1,6 @@ package net.krlite.bounced; import net.fabricmc.api.ModInitializer; -import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -28,10 +27,6 @@ public long queue() { public long queueElapsed() { return System.currentTimeMillis() - origin; } - - public double queueAsPercentage() { - return (double) queue() / (double) lasting; - } } public record Pusher(AtomicBoolean ready) { @@ -39,16 +34,16 @@ public Pusher(boolean ready) { this(new AtomicBoolean(ready)); } - public void let() { + public void push() { ready.set(true); } - public boolean queue() { - return ready.get(); + public boolean pull() { + return ready.get() && ready.getAndSet(false); } - public boolean access() { - return ready.getAndSet(false); + public void and(boolean and, Runnable runnable) { + if (and && pull()) runnable.run(); } } diff --git a/src/main/java/net/krlite/bounced/mixin/MinecraftAnimator.java b/src/main/java/net/krlite/bounced/mixin/MinecraftAnimator.java index 2f6b94a..c2d2a4b 100644 --- a/src/main/java/net/krlite/bounced/mixin/MinecraftAnimator.java +++ b/src/main/java/net/krlite/bounced/mixin/MinecraftAnimator.java @@ -21,7 +21,7 @@ class Trigger { @Inject(method = "setScreen", at = @At("TAIL")) private void trigger(Screen screen, CallbackInfo ci) { - if (!(screen instanceof TitleScreen)) PUSHER.let(); + if (!(screen instanceof TitleScreen)) PUSHER.push(); } } @@ -31,7 +31,8 @@ private void trigger(Screen screen, CallbackInfo ci) { @Mixin(TitleScreen.class) public class MinecraftAnimator { private Bounced.Timer timer = new Bounced.Timer(853); - private double yPos = 0; + private final double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 3.5; + private double yPos; /** * Triggers the animation when the title is first rendered. @@ -48,7 +49,7 @@ public class MinecraftAnimator { ) private float trigger(float alpha) { // Short-circuit manipulation - if (alpha > 0 && PUSHER.access()) timer = timer.reset(); + PUSHER.and(alpha > 0, () -> timer = timer.reset()); return alpha; } @@ -58,12 +59,14 @@ private float trigger(float alpha) { @Inject( method = "render", at = @At( - value = "FIELD", target = "Lnet/minecraft/client/gui/screen/TitleScreen;MINECRAFT_TITLE_TEXTURE:Lnet/minecraft/util/Identifier;", + value = "INVOKE", target = "Lcom/mojang/blaze3d/systems/RenderSystem;setShaderColor(FFFF)V", shift = At.Shift.AFTER + ), + slice = @Slice( + from = @At(value = "FIELD", target = "Lnet/minecraft/client/gui/screen/TitleScreen;MINECRAFT_TITLE_TEXTURE:Lnet/minecraft/util/Identifier;") ) ) private void animate(MatrixStack matrixStack, int mouseX, int mouseY, float delta, CallbackInfo ci) { - double offset = MinecraftClient.getInstance().getWindow().getScaledHeight() / 3.5; yPos = Bounced.easeOutBounce(-offset, offset, timer); }