diff options
| author | Kevin <92656833+kevinthegreat1@users.noreply.github.com> | 2024-07-26 15:15:12 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-26 15:15:12 +0800 |
| commit | 8288c1b0da604db3242dd848c3a66e0c7f0edc88 (patch) | |
| tree | 0f29c27291685e6974eebf8f683814f7c13af5ba /src/main/java/de/hysky/skyblocker/skyblock/quicknav | |
| parent | f53edcc01a94be3da0e83d2fc0fe4d13f58f13da (diff) | |
| parent | 8f27eb76273fe8424d44c2a1e08e45454e76b77c (diff) | |
| download | Skyblocker-8288c1b0da604db3242dd848c3a66e0c7f0edc88.tar.gz Skyblocker-8288c1b0da604db3242dd848c3a66e0c7f0edc88.tar.bz2 Skyblocker-8288c1b0da604db3242dd848c3a66e0c7f0edc88.zip | |
Merge pull request #812 from LifeIsAParadox/Quicknav-and-livid-fix
emi/rei, Quicknav, livid and nukekubi head (eman boss head) fix
Diffstat (limited to 'src/main/java/de/hysky/skyblocker/skyblock/quicknav')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java | 39 |
1 files changed, 34 insertions, 5 deletions
diff --git a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java index f7f33d0f..75c25e58 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/quicknav/QuickNavButton.java @@ -18,10 +18,16 @@ import net.minecraft.util.Identifier; @Environment(value = EnvType.CLIENT) public class QuickNavButton extends ClickableWidget { private final int index; - private boolean toggled; + private final boolean toggled; + private boolean temporaryToggled = false; private final String command; private final ItemStack icon; + private static final long TOGGLE_DURATION = 1000; + private long toggleTime; + + private float alpha = 1.0f; + /** * Checks if the current tab is a top tab based on its index. * @@ -32,7 +38,7 @@ public class QuickNavButton extends ClickableWidget { } public boolean toggled() { - return toggled; + return toggled || temporaryToggled; } /** @@ -49,6 +55,7 @@ public class QuickNavButton extends ClickableWidget { this.toggled = toggled; this.command = command; this.icon = icon; + this.toggleTime = 0; } private void updateCoordinates() { @@ -71,10 +78,12 @@ public class QuickNavButton extends ClickableWidget { */ @Override public void onClick(double mouseX, double mouseY) { - if (!this.toggled) { - this.toggled = true; + if (!this.temporaryToggled) { + this.temporaryToggled = true; + this.toggleTime = System.currentTimeMillis(); MessageScheduler.INSTANCE.sendMessageAfterCooldown(command); // TODO : add null check with log error + this.alpha = 0.5f; } } @@ -93,14 +102,34 @@ public class QuickNavButton extends ClickableWidget { this.updateCoordinates(); RenderSystem.disableDepthTest(); + if (this.temporaryToggled && System.currentTimeMillis() - this.toggleTime >= TOGGLE_DURATION) { + this.temporaryToggled = false; // Reset toggled state + } + //"animation" + if (this.alpha < 1.0f) { + this.alpha += 0.05f; + if (this.alpha > 1.0f) { + this.alpha = 1.0f; + } + } + + //"animation" + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, this.alpha); + // Construct the texture identifier based on the index and toggled state - Identifier tabTexture = Identifier.ofVanilla("container/creative_inventory/tab_" + (isTopTab() ? "top" : "bottom") + "_" + (toggled ? "selected" : "unselected") + "_" + (index % 7 + 1)); + Identifier tabTexture = Identifier.ofVanilla("container/creative_inventory/tab_" + (isTopTab() ? "top" : "bottom") + "_" + (toggled() ? "selected" : "unselected") + "_" + (index % 7 + 1)); // Render the button texture context.drawGuiTexture(tabTexture, this.getX(), this.getY(), this.width, this.height); // Render the button icon int yOffset = this.index < 7 ? 1 : -1; context.drawItem(this.icon, this.getX() + 5, this.getY() + 8 + yOffset); + //prevent "fading animation" on not quicknav stuff + RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f); + RenderSystem.disableBlend(); + RenderSystem.enableDepthTest(); } |
