aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
diff options
context:
space:
mode:
authorBuildTools <james.jenour@protonmail.com>2020-07-08 16:28:49 +1000
committerBuildTools <james.jenour@protonmail.com>2020-07-08 16:28:49 +1000
commit7bdf7f256fe3968fe7129928c0a7100c30628bf9 (patch)
tree222deed2be57223e3b1703a638843fbf21a254e7 /src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
parentf39c28236bc47a9e5395b041b494fdd7f332734e (diff)
downloadnotenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.gz
notenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.tar.bz2
notenoughupdates-7bdf7f256fe3968fe7129928c0a7100c30628bf9.zip
1.9.7
Diffstat (limited to 'src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
index 0beee610..2084c609 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/util/Utils.java
@@ -5,6 +5,8 @@ import com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService;
import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication;
import io.github.moulberry.notenoughupdates.util.TexLoc;
import net.minecraft.client.Minecraft;
+import net.minecraft.client.audio.PositionedSoundRecord;
+import net.minecraft.client.audio.SoundHandler;
import net.minecraft.client.gui.FontRenderer;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.client.renderer.GlStateManager;
@@ -19,6 +21,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.nbt.NBTTagString;
+import net.minecraft.util.ResourceLocation;
import net.minecraft.util.Session;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@@ -123,6 +126,15 @@ public class Utils {
return in.replaceAll("(?i)\\u00A7.", "");
}
+ public static String prettyCase(String str) {
+ return str.substring(0, 1).toUpperCase() + str.substring(1).toLowerCase();
+ }
+
+ public static void playPressSound() {
+ Minecraft.getMinecraft().getSoundHandler().playSound(PositionedSoundRecord.create(
+ new ResourceLocation("gui.button.press"), 1.0F));
+ }
+
public static void drawTexturedRect(float x, float y, float width, float height, float uMin, float uMax, float vMin, float vMax, int filter) {
GlStateManager.enableTexture2D();
GlStateManager.enableBlend();
@@ -293,6 +305,34 @@ public class Utils {
return trim;
}
+ public static void drawGradientRect(int left, int top, int right, int bottom, int startColor, int endColor) {
+ float f = (float)(startColor >> 24 & 255) / 255.0F;
+ float f1 = (float)(startColor >> 16 & 255) / 255.0F;
+ float f2 = (float)(startColor >> 8 & 255) / 255.0F;
+ float f3 = (float)(startColor & 255) / 255.0F;
+ float f4 = (float)(endColor >> 24 & 255) / 255.0F;
+ float f5 = (float)(endColor >> 16 & 255) / 255.0F;
+ float f6 = (float)(endColor >> 8 & 255) / 255.0F;
+ float f7 = (float)(endColor & 255) / 255.0F;
+ GlStateManager.disableTexture2D();
+ GlStateManager.enableBlend();
+ GlStateManager.disableAlpha();
+ GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
+ GlStateManager.shadeModel(7425);
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION_COLOR);
+ worldrenderer.pos((double)right, (double)top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos((double)left, (double)top, 0).color(f1, f2, f3, f).endVertex();
+ worldrenderer.pos((double)left, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
+ worldrenderer.pos((double)right, (double)bottom, 0).color(f5, f6, f7, f4).endVertex();
+ tessellator.draw();
+ GlStateManager.shadeModel(7424);
+ GlStateManager.disableBlend();
+ GlStateManager.enableAlpha();
+ GlStateManager.enableTexture2D();
+ }
+
public static void drawHoveringText(List<String> textLines, final int mouseX, final int mouseY, final int screenWidth, final int screenHeight, final int maxTextWidth, FontRenderer font) {
if (!textLines.isEmpty())
{