From 406021a5a79f220d40fbce73c95440b3ade5eb83 Mon Sep 17 00:00:00 2001 From: jani270 <69345714+jani270@users.noreply.github.com> Date: Thu, 14 Dec 2023 18:03:58 +0100 Subject: Added option for old cooldowns (#968) Co-authored-by: nopo --- .../notenoughupdates/mixins/MixinRenderItem.java | 23 ++++++++++++++++------ .../options/separatesections/ItemOverlays.java | 12 +++++++++-- 2 files changed, 27 insertions(+), 8 deletions(-) (limited to 'src/main/java') diff --git a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java index 9705742b..f8e1b432 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/mixins/MixinRenderItem.java @@ -22,7 +22,6 @@ package io.github.moulberry.notenoughupdates.mixins; import io.github.moulberry.notenoughupdates.NEUOverlay; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.ChromaColour; -import io.github.moulberry.notenoughupdates.core.util.render.RenderUtils; import io.github.moulberry.notenoughupdates.listener.RenderListener; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCooldowns; import io.github.moulberry.notenoughupdates.miscfeatures.ItemCustomizeManager; @@ -41,8 +40,6 @@ import net.minecraft.client.renderer.vertex.DefaultVertexFormats; import net.minecraft.client.resources.model.IBakedModel; import net.minecraft.item.Item; import net.minecraft.item.ItemStack; -import net.minecraft.util.MathHelper; -import net.minecraftforge.fml.client.config.GuiUtils; import org.lwjgl.opengl.GL11; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -243,10 +240,24 @@ public abstract class MixinRenderItem { if (damageOverride >= 0) { GlStateManager.disableLighting(); GlStateManager.disableDepth(); - GlStateManager.enableAlpha(); - - Utils.drawRect(xPosition, yPosition + 16.0f * (1.0f - damageOverride), xPosition + 16, yPosition + 16, Integer.MAX_VALUE); + if (NotEnoughUpdates.INSTANCE.config.itemOverlays.oldCooldowns) { + float barX = 13.0f - damageOverride * 13.0f; + int col = (int) Math.round(255.0D - damageOverride * 255.0D); + GlStateManager.disableTexture2D(); + GlStateManager.disableAlpha(); + GlStateManager.disableBlend(); + Tessellator tessellator = Tessellator.getInstance(); + WorldRenderer worldrenderer = tessellator.getWorldRenderer(); + func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 13, 2, 0, 0, 0, 255); + func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, 12, 1, (255 - col) / 4, 64, 0, 255); + func_181565_a(worldrenderer, xPosition + 2, yPosition + 13, barX, 1, 255 - col, col, 0, 255); + GlStateManager.enableAlpha(); + GlStateManager.enableTexture2D(); + } else { + GlStateManager.enableAlpha(); + Utils.drawRect(xPosition, yPosition + 16.0f * (1.0f - damageOverride), xPosition + 16, yPosition + 16, Integer.MAX_VALUE); + } GlStateManager.enableLighting(); GlStateManager.enableDepth(); } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java index 4606a78f..a5cd6cb7 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ItemOverlays.java @@ -20,16 +20,16 @@ package io.github.moulberry.notenoughupdates.options.separatesections; import com.google.gson.annotations.Expose; -import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; -import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.moulconfig.annotations.ConfigAccordionId; import io.github.moulberry.moulconfig.annotations.ConfigEditorAccordion; import io.github.moulberry.moulconfig.annotations.ConfigEditorBoolean; import io.github.moulberry.moulconfig.annotations.ConfigEditorColour; import io.github.moulberry.moulconfig.annotations.ConfigEditorDraggableList; import io.github.moulberry.moulconfig.annotations.ConfigEditorDropdown; +import io.github.moulberry.moulconfig.annotations.ConfigEditorInfoText; import io.github.moulberry.moulconfig.annotations.ConfigEditorSlider; import io.github.moulberry.moulconfig.annotations.ConfigOption; +import io.github.moulberry.notenoughupdates.core.config.Position; import java.util.ArrayList; import java.util.Arrays; @@ -462,6 +462,14 @@ public class ItemOverlays { @ConfigEditorInfoText() public boolean customWitherCloakCredit = false; + @Expose + @ConfigOption( + name = "Use Durability for Cooldowns", + desc = "Show the cooldown durations as the durability." + ) + @ConfigEditorBoolean + public boolean oldCooldowns = false; + @Expose @ConfigOption( name = "Pickaxe Ability Cooldown", -- cgit