From 17cfe96255f1ec3ab5609aa153d4abed2075c435 Mon Sep 17 00:00:00 2001 From: DeDiamondPro <67508414+DeDiamondPro@users.noreply.github.com> Date: Sun, 4 Sep 2022 13:29:43 +0200 Subject: Disable the flashbang feature (#124) Bang! I get up, I get down and I'm jumping around And the rumpus and ruckus are comfortable now Been a hell of a ride but I'm thinking it's time to grow Bang! Bang! Bang! So I got an apartment across from the park Put quinoa in my fridge, still I'm not feeling grown Been a hell of a ride but I'm thinking it's time to go Bang! Bang! Bang! (Here we go) So put your best face on everybody Pretend you know this song Everybody come hang (come hang) Let's go out with a bang Bang! Bang! Bang! I'm way too young to lie here forever I'm way too old to try so whatever come hang (come hang) Let's go out with a bang Bang! Bang! Bang! Feel like I'm gonna puke 'cause my taxes are due Do my password begin with a one or a two? Been a hell of a ride but I'm thinking it's time to grow Bang! Bang! Bang! (Metronome) Man, I'm up to something (up to something) Ooh de la de do, thank you all for coming (all for coming) I hope you like the show 'Cause it's on a budget (on a budget) So ooh de la de do Yeah, come on, here we go Yeah, come on (Here we go) So put your best face on everybody Pretend you know this song Everybody come hang (come hang) Let's go out with a bang Bang! Bang! Bang! I'm way too young to lie here forever I'm way too old to try so whatever come hang (come hang) Let's go out with a bang Bang! Bang! Bang! (Bang! Bang! Bang! Bang!) Bang! Bang! Bang! (Bang! Bang! Bang! Bang! Bang! Bang!) Been a hell of a ride but I'm thinking it's time to go So put your best face on everybody Pretend you know this song Everybody come hang Let's go out with a bang Bang! Bang! Bang! (Here we go) So put your best face on everybody Pretend you know this song Everybody come hang (come hang) Let's go out with a bang Bang! Bang! Bang! (Bang! Bang! Bang! Bang! Bang! Bang!) I'm way too young to lie here forever I'm way too old to try so whatever come hang (come hang) Let's go out with a bang Bang! Bang! Bang! (Here we go) Bang! Bang! --- .../polyfrost/oneconfig/gui/pages/CreditsPage.java | 4 +- .../oneconfig/internal/utils/Notification.java | 4 +- .../polyfrost/oneconfig/utils/Notifications.java | 15 ++++++- .../oneconfig/internal/mixin/HudCachingMixin.java | 50 ++++++++++++++++++++++ .../oneconfig/internal/mixin/HudCachingMixin.java | 50 ++++++++++++++++++++++ .../internal/plugin/OneConfigMixinPlugin.java | 3 ++ 6 files changed, 121 insertions(+), 5 deletions(-) create mode 100644 versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java create mode 100644 versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java diff --git a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java index e8a44e5..89e2d9d 100644 --- a/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java +++ b/src/main/java/cc/polyfrost/oneconfig/gui/pages/CreditsPage.java @@ -48,13 +48,13 @@ public class CreditsPage extends Page { RenderManager.drawText(vg, " - DeDiamondPro - Founder, Config backend, GUI frontend, HUD", x + 20, y + 220, -1, 12, Fonts.REGULAR); // +15/line RenderManager.drawText(vg, " - nextdaydelivery - GUI frontend, Render Manager, Utilities", x + 20, y + 235, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - Wyvest - Gradle, Render Manager, VCAL, Utilities", x + 20, y + 250, -1, 12, Fonts.REGULAR); - RenderManager.drawText(vg, " - Ethan - Utilities", x + 20, y + 265, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - Pauline - Utilities", x + 20, y + 265, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, "Libraries", x + 20, y + 318, -1, 24, Fonts.SEMIBOLD); RenderManager.drawText(vg, " - LWJGLTwoPointFive (DJTheRedstoner) - LWJGL3 loading hack", x + 20, y + 340, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - #getResourceAsStream (SpinyOwl) - IO Utility and shadow", x + 20, y + 355, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - NanoVG (memononen) - NanoVG Library", x + 20, y + 370, -1, 12, Fonts.REGULAR); - RenderManager.drawText(vg, " - UniversalCraft (Sk1er LLC) - Multiversioning bindings", x + 20, y + 385, -1, 12, Fonts.REGULAR); + RenderManager.drawText(vg, " - UniversalCraft (Essential team) - Multiversioning bindings", x + 20, y + 385, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - https://easings.net/ - Easing functions", x + 20, y + 400, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - Quiltflower (Quilt Team) - Gradle decompiler", x + 20, y + 415, -1, 12, Fonts.REGULAR); RenderManager.drawText(vg, " - Seraph (Scherso) - Locraw and Multithreading utilities", x + 20, y + 430, -1, 12, Fonts.REGULAR); diff --git a/src/main/java/cc/polyfrost/oneconfig/internal/utils/Notification.java b/src/main/java/cc/polyfrost/oneconfig/internal/utils/Notification.java index e2c0b05..5d18580 100644 --- a/src/main/java/cc/polyfrost/oneconfig/internal/utils/Notification.java +++ b/src/main/java/cc/polyfrost/oneconfig/internal/utils/Notification.java @@ -69,10 +69,10 @@ public final class Notification { this.action = action; } - public float draw(final long vg, float y, float scale) { + public float draw(final long vg, float y, float scale, float deltaTime) { RenderManager.scale(vg, scale, scale); inputHandler.scale(scale, scale); - float x = (UResolution.getWindowWidth() / scale - animation.get(hovered ? 0 : GuiUtils.getDeltaTime())); + float x = (UResolution.getWindowWidth() / scale - animation.get(hovered ? 0 : deltaTime)); float textX = icon == null ? x + 16 : x + 64; float textMaxLength = icon == null ? 268 : 220; float messageHeight = RenderManager.getWrappedStringHeight(vg, message, textMaxLength, 12f, 1.75f, Fonts.REGULAR); diff --git a/src/main/java/cc/polyfrost/oneconfig/utils/Notifications.java b/src/main/java/cc/polyfrost/oneconfig/utils/Notifications.java index b1fb387..2e64040 100644 --- a/src/main/java/cc/polyfrost/oneconfig/utils/Notifications.java +++ b/src/main/java/cc/polyfrost/oneconfig/utils/Notifications.java @@ -27,6 +27,8 @@ package cc.polyfrost.oneconfig.utils; import cc.polyfrost.oneconfig.events.event.HudRenderEvent; +import cc.polyfrost.oneconfig.events.event.RenderEvent; +import cc.polyfrost.oneconfig.events.event.Stage; import cc.polyfrost.oneconfig.gui.OneConfigGui; import cc.polyfrost.oneconfig.gui.animations.Animation; import cc.polyfrost.oneconfig.gui.animations.DummyAnimation; @@ -36,6 +38,7 @@ import cc.polyfrost.oneconfig.libs.eventbus.Subscribe; import cc.polyfrost.oneconfig.libs.universal.UResolution; import cc.polyfrost.oneconfig.renderer.Icon; import cc.polyfrost.oneconfig.renderer.RenderManager; +import cc.polyfrost.oneconfig.utils.gui.GuiUtils; import org.jetbrains.annotations.Nullable; import java.util.LinkedHashMap; @@ -219,6 +222,8 @@ public final class Notifications { send(title, message, (Callable) null); } + private float deltaTime = 0; + @Subscribe private void onHudRender(HudRenderEvent event) { RenderManager.setupAndDraw((vg) -> { @@ -229,10 +234,18 @@ public final class Notifications { entry.setValue(new DummyAnimation(desiredPosition)); else if (desiredPosition != entry.getValue().getEnd()) entry.setValue(new EaseInOutQuad(250, entry.getValue().get(0), desiredPosition, false)); - float height = entry.getKey().draw(vg, UResolution.getWindowHeight() / scale + entry.getValue().get(), scale); + float height = entry.getKey().draw(vg, UResolution.getWindowHeight() / scale + entry.getValue().get(deltaTime), scale, deltaTime); desiredPosition -= height + 16f; } notifications.entrySet().removeIf(entry -> entry.getKey().isFinished()); }); + deltaTime = 0; + } + + @Subscribe + private void onRenderEvent(RenderEvent event) { + if (event.stage == Stage.START) { + deltaTime += GuiUtils.getDeltaTime(); // add up deltatime since we might not render every frame because of hud caching + } } } diff --git a/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java new file mode 100644 index 0000000..3348aef --- /dev/null +++ b/versions/1.12.2-forge/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java @@ -0,0 +1,50 @@ +/* + * This file is part of OneConfig. + * OneConfig - Next Generation Config Library for Minecraft: Java Edition + * Copyright (C) 2021, 2022 Polyfrost. + * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * OneConfig is licensed under the terms of version 3 of the GNU Lesser + * General Public License as published by the Free Software Foundation, AND + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, + * either version 1.0 of the Additional Terms, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License. If not, see . You should + * have also received a copy of the Additional Terms Applicable + * to OneConfig, as published by Polyfrost. If not, see + * + */ + +//#if MC==11202 +package cc.polyfrost.oneconfig.internal.mixin; + +import net.minecraft.client.shader.Framebuffer; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Pseudo +@Mixin(targets = "club.sk1er.patcher.screen.render.caching.HUDCaching", remap = false) +public class HudCachingMixin { + + @Dynamic + @Inject(method = "checkFramebufferSizes", at = @At(value = "RETURN", ordinal = 0), remap = false) + private static void checkFramebufferSizes(Framebuffer framebuffer, int width, int height, CallbackInfoReturnable cir) { + if (cir.getReturnValue() != null && !cir.getReturnValue().isStencilEnabled()) { + cir.getReturnValue().enableStencil(); + } + } +} +//#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java new file mode 100644 index 0000000..4324bb2 --- /dev/null +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/mixin/HudCachingMixin.java @@ -0,0 +1,50 @@ +/* + * This file is part of OneConfig. + * OneConfig - Next Generation Config Library for Minecraft: Java Edition + * Copyright (C) 2021, 2022 Polyfrost. + * + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * OneConfig is licensed under the terms of version 3 of the GNU Lesser + * General Public License as published by the Free Software Foundation, AND + * under the Additional Terms Applicable to OneConfig, as published by Polyfrost, + * either version 1.0 of the Additional Terms, or (at your option) any later + * version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License. If not, see . You should + * have also received a copy of the Additional Terms Applicable + * to OneConfig, as published by Polyfrost. If not, see + * + */ + +//#if MC==10809 +package cc.polyfrost.oneconfig.internal.mixin; + +import net.minecraft.client.shader.Framebuffer; +import org.spongepowered.asm.mixin.Dynamic; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Pseudo; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; + +@Pseudo +@Mixin(targets = "club.sk1er.patcher.screen.render.caching.HUDCaching", remap = false) +public class HudCachingMixin { + + @Dynamic + @Inject(method = "checkFramebufferSizes", at = @At(value = "RETURN", ordinal = 0), remap = false) + private static void checkFramebufferSizes(Framebuffer framebuffer, int width, int height, CallbackInfoReturnable cir) { + if (cir.getReturnValue() != null && !cir.getReturnValue().isStencilEnabled()) { + cir.getReturnValue().enableStencil(); + } + } +} +//#endif \ No newline at end of file diff --git a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java index e242e2f..a5dd29d 100644 --- a/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java +++ b/versions/src/main/java/cc/polyfrost/oneconfig/internal/plugin/OneConfigMixinPlugin.java @@ -86,6 +86,9 @@ public class OneConfigMixinPlugin implements IMixinConfigPlugin { mixins.add("TickTimeTrackerMixin"); return mixins; } + if (Platform.getInstance().getMinecraftVersion() == 10800 || Platform.getInstance().getMinecraftVersion() == 11200) { + mixins.add("HudCachingMixin"); + } return mixins.isEmpty() ? null : mixins; } -- cgit