diff options
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils')
17 files changed, 0 insertions, 2851 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java deleted file mode 100644 index 049f8a0d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/AhUtils.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.utils; - -import java.security.*; -import java.security.cert.CertificateException; -import java.util.HashMap; -import java.util.Map; - -import com.google.gson.JsonElement; -import com.google.gson.JsonObject; -import kr.syeyoung.dungeonsguide.DungeonsGuide; - -import javax.crypto.BadPaddingException; -import javax.crypto.IllegalBlockSizeException; -import javax.crypto.NoSuchPaddingException; -import java.util.Timer; -import java.util.TimerTask; - -public class AhUtils { - public static volatile Map<String, AuctionData> auctions = new HashMap<String, AuctionData>(); - - public static Timer timer = new Timer(); - - public static int totalAuctions = 0; - - public static void registerTimer() { - timer.schedule(new TimerTask() { - public void run() { - try { - AhUtils.loadAuctions(); - } catch (CertificateException | NoSuchAlgorithmException | InvalidKeyException | InvalidAlgorithmParameterException | NoSuchPaddingException | BadPaddingException | KeyStoreException | IllegalBlockSizeException | KeyManagementException e) { - e.printStackTrace(); - } - } - }, 0L, 1800000L); - } - - public static void loadAuctions() throws CertificateException, NoSuchAlgorithmException, InvalidKeyException, InvalidAlgorithmParameterException, NoSuchPaddingException, BadPaddingException, KeyStoreException, IllegalBlockSizeException, KeyManagementException { - try { - - Map<String, AuctionData> semi_auctions = new HashMap<String, AuctionData>(); - JsonElement object = DungeonsGuide.getDungeonsGuide().getAuthenticator().getJsonSecured("https://dungeons.guide/resource/keys"); - for (JsonElement element : object.getAsJsonArray()) { - JsonObject object1 = element.getAsJsonObject(); - AuctionData auctionData = new AuctionData(object1.get("id").getAsString()); - auctionData.lowestBin = object1.get("lowestBin").getAsInt(); - auctionData.sellPrice = object1.get("sellPrice").getAsInt(); - auctionData.buyPrice = object1.get("buyPrice").getAsInt(); - semi_auctions.put(auctionData.id, auctionData); - } - auctions = semi_auctions; - } catch (Throwable e) { - e.printStackTrace(); - } - } - - public static class AuctionData { - public String id; - - public long lowestBin = -1; - - public int sellPrice = -1; - - public int buyPrice = -1; - - public AuctionData(String id) { - this.id = id; - } - } -}
\ No newline at end of file diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java deleted file mode 100755 index 8b84da13..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/ArrayUtils.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.utils; - -public class ArrayUtils { - public static int[][] rotateCounterClockwise(int[][] arr) { - int[][] res = new int[arr[0].length][arr.length]; - for(int y=0; y<arr.length; y++) { - for (int x = 0; x< arr[0].length; x++) { - res[res.length - x - 1][y] = arr[y][x]; - } - } - return res; - } - public static int[][] rotateClockwise(int[][] arr) { - int[][] res = new int[arr[0].length][arr.length]; - for(int y=0; y<arr.length; y++) { - for (int x = 0; x< arr[0].length; x++) { - res[x][res[0].length - y - 1] = arr[y][x]; - } - } - return res; - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java deleted file mode 100644 index 2737be9d..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/GlStateUtils.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.utils; - -import com.sun.org.apache.xpath.internal.operations.Bool; -import net.minecraft.client.renderer.GlStateManager; - -import java.lang.reflect.Field; -import java.util.*; - -public class GlStateUtils { - public static Map<String, Object> dumpStates() { - Map<String, Object> primitiveDump = new LinkedHashMap<>(); - try { - recursivelyDump(primitiveDump, "GlStateManager", null, GlStateManager.class); - } catch (IllegalAccessException e) { - e.printStackTrace(); - primitiveDump.put("$ERROR", true); - } - return primitiveDump; - } - - public static void printDump(Map<String, Object> dump) { - for (Map.Entry<String, Object> stringObjectEntry : dump.entrySet()) { - System.out.println(stringObjectEntry+": "+stringObjectEntry.getValue()); - } - } - - public static void compareDump(Map<String, Object> dump1, Map<String,Object> dump2) { - Set<String> set = new HashSet<>(); - set.addAll(dump1.keySet()); - set.addAll(dump2.keySet()); - - for (String s : set) { - Object obj1 = dump1.get(s); - Object obj2 = dump2.get(s); - if (!Objects.equals(obj1, obj2)) System.out.println(s+": Prev {"+obj1+"} New {"+obj2+"}"); - } - } - - public static void recursivelyDump(Map<String, Object> primitiveDump, String objPath, Object obj, Class clazz) throws IllegalAccessException { - primitiveDump.put(objPath+".$class", clazz.getName()); - for (Field declaredField : clazz.getDeclaredFields()) { - declaredField.setAccessible(true); - Object fieldData = declaredField.get(obj); - if (fieldData.getClass().getName().startsWith("java.lang")) { - primitiveDump.put(objPath+"."+declaredField.getName(), fieldData); - } else { - recursivelyDump(primitiveDump, objPath+"."+declaredField.getName(), fieldData, fieldData.getClass()); - } - } - } -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java deleted file mode 100755 index 8fb90ec1..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/MapUtils.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.utils; - -import lombok.Getter; -import net.minecraft.block.material.MapColor; -import org.w3c.dom.css.Rect; - -import javax.vecmath.Vector2d; -import java.awt.*; -import java.awt.image.BufferedImage; - -public class MapUtils { - - private static Color[] colorMasks = new Color[128 * 128]; - @Getter - private static byte[] colors; - - public static void clearMap() { - colorMasks = new Color[128 * 128]; - colors = null; - } - - public static void record(byte[] colors, int x, int y, Color c) { - MapUtils.colors = colors; - colorMasks[y *128 +x] = c; - } - - public static byte getMapColorAt(byte[] colors, int x, int y) { - if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; - return colors[y * 128 +x]; - } - - public static BufferedImage getImage() { - BufferedImage bufferedImage = new BufferedImage(128, 128,BufferedImage.TYPE_INT_ARGB); - if (colors == null) return bufferedImage; - Graphics graphics = bufferedImage.getGraphics(); - for (int y = 0; y < 128; y++) { - for (int x = 0; x <128; x++) { - bufferedImage.setRGB(x,y, getRGBColorAt(colors, x, y)); - if (colorMasks[y * 128 + x] != null) { - graphics.setColor(colorMasks[y *128 +x]); - graphics.drawLine(x,y,x,y); - } - } - } - return bufferedImage; - } - - public static int getRGBColorAt(byte[] colors, int x, int y) { - if (y <0 || y>= 128 || x < 0 || x >= 128) return 0; - int i = y * 128 +x; - int j = colors[i] & 255; - - int theColor; - if (j / 4 == 0) - { - theColor = (i + i / 128 & 1) * 8 + 16 << 24; - } - else - { - theColor = MapColor.mapColorArray[j / 4].getMapColor(j & 3); - } - - return theColor; - } - - public static Point findFirstColorWithIn(byte[] colors, byte color, Rectangle dimension) { - boolean found = true; - for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { - for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { - if (getMapColorAt(colors, x ,y) == color && found) { - record(colors, x, y, new Color(255, 0, 0, 40)); - return new Point(x,y); - } - found = getMapColorAt(colors, x,y) == 0; - } - } - return null; - } - - public static Point findFirstColorWithInNegate(byte[] colors, byte color, Rectangle dimension) { - for (int y = dimension.y; y < (dimension.y + dimension.height);y++) { - for (int x = dimension.x; x < (dimension.x + dimension.width); x ++) { - if (getMapColorAt(colors, x ,y) != color) { - record(colors, x, y, new Color(255, 0, 0, 40)); - return new Point(x,y); - } - } - } - return null; - } - - public static int getWidthOfColorAt(byte[] colors, byte color, Point point) { - for (int x = point.x; x < 128; x++) { - record(colors, x, point.y, new Color(0, 255, 0, 40)); - if (getMapColorAt(colors, x, point.y) != color) return x - point.x; - } - return 128 - point.x; - } - public static int getHeightOfColorAt(byte[] colors, byte color, Point point) { - for (int y = point.y; y < 128; y++) { - record(colors, point.x, y, new Color(0, 255, 0, 40)); - if (getMapColorAt(colors, point.x,y) != color) return y - point.y; - } - return 128 - point.y; - } - - public static int getLengthOfColorExtending(byte[] colors, byte color, Point basePoint, Vector2d vector2d) { - for (int i = 0; i < 128; i++) { - int x = (int) (basePoint.x + vector2d.x * i); - int y = (int) (basePoint.y + vector2d.y * i); - record(colors, x, y, new Color(0, 0, 255, 40)); - if (getMapColorAt(colors, x,y) != color) return i; - } - return -1; - } - - - public static boolean matches(byte[] colors, byte[] stencil, int targetColor, int x, int y) { - for (int i = y; i < y + stencil.length; i++) { - for (int j = x; j < x + 8; j++) { - boolean current = getMapColorAt(colors, j, i) == targetColor; - boolean expected = ((stencil[i - y] >> (7-(j-x))) & 0x1) == 1; - if (current != expected) return false; - } - } - return true; - } - - public static int readDigit(byte[] colors, int x, int y) { - for (int i = 0; i < NUMBER_STENCIL.length; i++) { - if (matches(colors, NUMBER_STENCIL[i],34, x, y)) return i; - } - return -1; - } - public static int readNumber(byte[] colors, int x, int y, int gap) { - int number = 0; - for (int i = x; i < 128; i += gap) { - int digit = readDigit(colors, i, y); - if (digit != -1) number = number * 10 + digit; - } - return number; - } - - private static final byte[][] NUMBER_STENCIL = { - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x1E, 0x1E, 0x1E, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0xE, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x77, 0x77, 0x7, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x1F, 0x1F, 0x7, 0x7, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x6E, 0x7F, 0x7F, 0x7F, 0xE, 0xE, 0xE, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x7, 0x77, 0x77, 0x7F, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x70, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x7F, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x7, 0x0}, - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x3E, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x0}, - {0x0, 0x7F, 0x7F, 0x77, 0x77, 0x77, 0x77, 0x7F, 0x7F, 0x7, 0x7F, 0x7F, 0x7F, 0x0} - }; - - - -} diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java deleted file mode 100755 index 18f09cb0..00000000 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ /dev/null @@ -1,1377 +0,0 @@ -/* - * Dungeons Guide - The most intelligent Hypixel Skyblock Dungeons Mod - * Copyright (C) 2021 cyoung06 - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License as published - * by the Free Software Foundation, either version 3 of the License, 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see <https://www.gnu.org/licenses/>. - */ - -package kr.syeyoung.dungeonsguide.utils; - -import kr.syeyoung.dungeonsguide.config.types.AColor; -import kr.syeyoung.dungeonsguide.dungeon.doorfinder.DungeonDoor; -import net.minecraft.client.Minecraft; -import net.minecraft.client.entity.EntityOtherPlayerMP; -import net.minecraft.client.entity.EntityPlayerSP; -import net.minecraft.client.gui.FontRenderer; -import net.minecraft.client.gui.ScaledResolution; -import net.minecraft.client.renderer.GlStateManager; -import net.minecraft.client.renderer.RenderHelper; -import net.minecraft.client.renderer.Tessellator; -import net.minecraft.client.renderer.WorldRenderer; -import net.minecraft.client.renderer.entity.RenderManager; -import net.minecraft.client.renderer.vertex.DefaultVertexFormats; -import net.minecraft.entity.Entity; -import net.minecraft.entity.item.EntityArmorStand; -import net.minecraft.entity.passive.EntityBat; -import net.minecraft.util.*; -import org.lwjgl.input.Keyboard; -import org.lwjgl.input.Mouse; -import org.lwjgl.opengl.GL11; -import org.lwjgl.opengl.GL14; - -import javax.vecmath.Vector3f; -import java.awt.*; -import java.util.List; - -public class RenderUtils { - public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); - private static final ResourceLocation beaconBeam = new ResourceLocation("textures/entity/beacon_beam.png"); - - /** - * Taken from NotEnoughUpdates under Creative Commons Attribution-NonCommercial 3.0 - * And modified to fit out need. - * https://github.com/Moulberry/NotEnoughUpdates/blob/master/LICENSE - * @author Moulberry - */ - public static void renderBeaconBeam(double x, double y, double z, AColor aColor, float partialTicks) { - Entity player = Minecraft.getMinecraft().thePlayer; - double playerX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; - double playerY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; - double playerZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; -//because of the way 3D rendering is done, all coordinates are relative to the camera. This "resets" the "0,0,0" position to the location that is (0,0,0) in the world. - - - GlStateManager.pushMatrix(); - GlStateManager.translate(-playerX, -playerY, -playerZ); - int height = 300; - int bottomOffset = 0; - int topOffset = bottomOffset + height; - - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - - Minecraft.getMinecraft().getTextureManager().bindTexture(beaconBeam); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, 10497.0F); - GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, 10497.0F); - GlStateManager.disableLighting(); - GlStateManager.disableDepth(); - GlStateManager.enableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0); - GlStateManager.enableBlend(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - - double time = Minecraft.getMinecraft().theWorld.getTotalWorldTime() + (double)partialTicks; - double d1 = MathHelper.func_181162_h(-time * 0.2D - (double)MathHelper.floor_double(-time * 0.1D)); - - int c = getColorAt(x,y,z, aColor); - float alpha = ((c >> 24) & 0xFF) / 255.0f; - - float r = ((c >> 16) & 0xFF) / 255f; - float g = ((c >> 8) & 0xFF) / 255f; - float b = (c & 0xFF) / 255f; - double d2 = time * 0.025D * -1.5D; - double d4 = 0.5D + Math.cos(d2 + 2.356194490192345D) * 0.2D; - double d5 = 0.5D + Math.sin(d2 + 2.356194490192345D) * 0.2D; - double d6 = 0.5D + Math.cos(d2 + (Math.PI / 4D)) * 0.2D; - double d7 = 0.5D + Math.sin(d2 + (Math.PI / 4D)) * 0.2D; - double d8 = 0.5D + Math.cos(d2 + 3.9269908169872414D) * 0.2D; - double d9 = 0.5D + Math.sin(d2 + 3.9269908169872414D) * 0.2D; - double d10 = 0.5D + Math.cos(d2 + 5.497787143782138D) * 0.2D; - double d11 = 0.5D + Math.sin(d2 + 5.497787143782138D) * 0.2D; - double d14 = -1.0D + d1; - double d15 = (double)(height) * 2.5D + d14; - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d6, y + topOffset, z + d7).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d6, y + bottomOffset, z + d7).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + bottomOffset, z + d11).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d10, y + topOffset, z + d11).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d8, y + topOffset, z + d9).tex(1.0D, d15).color(r, g, b, alpha).endVertex(); - worldrenderer.pos(x + d8, y + bottomOffset, z + d9).tex(1.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + bottomOffset, z + d5).tex(0.0D, d14).color(r, g, b, 1.0F).endVertex(); - worldrenderer.pos(x + d4, y + topOffset, z + d5).tex(0.0D, d15).color(r, g, b, alpha).endVertex(); - tessellator.draw(); - - double d12 = -1.0D + d1; - double d13 = height + d12; - - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.2D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.2D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + bottomOffset, z + 0.8D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.8D, y + topOffset, z + 0.8D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.8D).tex(1.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.8D).tex(1.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + bottomOffset, z + 0.2D).tex(0.0D, d12).color(r, g, b, 0.25F).endVertex(); - worldrenderer.pos(x + 0.2D, y + topOffset, z + 0.2D).tex(0.0D, d13).color(r, g, b, 0.25F*alpha).endVertex(); - tessellator.draw(); - - GlStateManager.enableDepth(); - - GlStateManager.popMatrix(); - } - - - public static void drawTexturedRect(float x, float y, float width, float height, int filter) { - drawTexturedRect(x, y, width, height, 0.0F, 1.0F, 0.0F, 1.0F, filter); - } - private static float zLevel = 0; - public static int scrollY = 0; - public static boolean allowScrolling; - public static int scrollX = 0; - - 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, (double)0).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)top, (double)0).color(f1, f2, f3, f).endVertex(); - worldrenderer.pos((double)left, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); - worldrenderer.pos((double)right, (double)bottom, (double)0).color(f5, f6, f7, f4).endVertex(); - tessellator.draw(); - GlStateManager.shadeModel(7424); - GlStateManager.enableAlpha(); - GlStateManager.enableTexture2D(); - } - - public static void drawRect(int left, int top, int right, int bottom, AColor color) - { - if (left < right) - { - int i = left; - left = right; - right = i; - } - - if (top < bottom) - { - int j = top; - top = bottom; - bottom = j; - } - - float f3 = (float)(color.getRGB() >> 24 & 255) / 255.0F; - float f = (float)(color.getRGB() >> 16 & 255) / 255.0F; - float f1 = (float)(color.getRGB() >> 8 & 255) / 255.0F; - float f2 = (float)(color.getRGB() & 255) / 255.0F; - if (!color.isChroma() && f3 == 0) return; - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - GlStateManager.enableBlend(); - GlStateManager.disableTexture2D(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0); - if (!color.isChroma()) { - GlStateManager.color(f, f1, f2, f3); - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION); - worldrenderer.pos(left, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, bottom, 0.0D).endVertex(); - worldrenderer.pos(right, top, 0.0D).endVertex(); - worldrenderer.pos(left, top, 0.0D).endVertex(); - } else { - worldrenderer.begin(GL11.GL_QUADS, DefaultVertexFormats.POSITION_COLOR); - GlStateManager.shadeModel(GL11.GL_SMOOTH); - color(worldrenderer.pos(left, bottom, 0.0D), getColorAt(left, bottom, color)).endVertex(); - color(worldrenderer.pos(right, bottom, 0.0D), getColorAt(right, bottom, color)).endVertex(); - color(worldrenderer.pos(right, top, 0.0D), getColorAt(right, top, color)).endVertex(); - color(worldrenderer.pos(left, top, 0.0D), getColorAt(left, top, color)).endVertex(); - } - tessellator.draw(); - GlStateManager.enableTexture2D(); - GlStateManager.disableBlend(); - } - - - public static void drawRoundedRectangle(int x, int y, int width, int height, int radius, double delta, int color) { - GlStateManager.pushMatrix(); - GlStateManager.translate(width/2.0+x, height/2.0+y, 0); - Tessellator t = Tessellator.getInstance(); - GlStateManager.disableTexture2D(); - RenderUtils.GL_SETCOLOR(color); - WorldRenderer wr = t.getWorldRenderer(); - wr.begin(GL11.GL_POLYGON, DefaultVertexFormats.POSITION); - for (double i = 0.1; i < Math.PI*2; i+= delta) { - double cos = MathHelper.cos((float) i); - double sin = MathHelper.sin((float) i); - if (cos * MathHelper.cos((float) (i + delta)) <= 0) { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius),0).endVertex(); - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? -1 : 1) * (height/2.0 - radius),0).endVertex(); - } else if (sin * MathHelper.sin((float) (i+delta)) <= 0) { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - wr.pos(sin * radius + (sin > 0 ? -1 : 1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - } else { - wr.pos(sin * radius + (sin > 0 ? 1 : -1) * (width/2.0 - radius), - cos * radius + (cos > 0 ? 1 : -1) * (height/2.0 - radius), 0).endVertex(); - } - } - t.draw(); - GlStateManager.popMatrix(); - } - - public static void GL_SETCOLOR(int color) { - float f3 = (float)(color >> 24 & 255) / 255.0F; - float f = (float)(color >> 16 & 255) / 255.0F; - float f1 = (float)(color >> 8 & 255) / 255.0F; - float f2 = (float)(color & 255) / 255.0F; - GlStateManager.color(f, f1, f2, f3); - } - - public static int blendTwoColors(int background, int newColor) { - float alpha = ((newColor >> 24) & 0xFF) /255.0f; - int r1 = (background >> 16) & 0xFF, r2 = (newColor >> 16) & 0xFF; - int g1 = (background >> 8) & 0xFF, g2 = (newColor >> 8) & 0xFF; - int b1 = (background) & 0xFF, b2 = (newColor) & 0xFF; - - int rr = (int) (r1 + (r2-r1) * alpha) & 0xFF; - int rg = (int) (g1 + (g2-g1) * alpha) & 0xFF; - int rb = (int) (b1 + (b2-b1) * alpha) & 0xFF; - return 0xFF000000 | ((rr << 16) & 0xFF0000) | ((rg << 8) & 0xFF00) | (rb & 0xFF); - } - - public static int blendAlpha(int origColor, float alphaPerc) { - return blendTwoColors(origColor, (int)(alphaPerc*255) << 24 | 0xFFFFFF); - } - - 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(); - GlStateManager.tryBlendFuncSeparate(770, 771, 1, 771); - GL11.glTexParameteri(3553, 10241, filter); - GL11.glTexParameteri(3553, 10240, filter); - Tessellator tessellator = Tessellator.getInstance(); - WorldRenderer worldrenderer = tessellator.getWorldRenderer(); - worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX); - worldrenderer.pos(x, y + height, 0.0D).tex(uMin, vMax).endVertex(); - worldrenderer.pos(x + width, y + height, 0.0D).tex(uMax, vMax).endVertex(); - worldrenderer.pos(x + width, y, 0.0D).tex(uMax, vMin).endVertex(); - worldrenderer.pos(x, y, 0.0D).tex(uMin, vMin).endVertex(); - tessellator.draw(); - GL11.glTexParameteri(3553, 10241, 9728); - GL11.glTexParameteri(3553, 10240, 9728); - GlStateManager.disableBlend(); - } - public static void renderBar(float x, float y, float xSize, float completed) { - Minecraft.getMinecraft().getTextureManager().bindTexture(icons); - completed = (float)Math.round(completed / 0.05F) * 0.05F; - float notcompleted = 1.0F - completed; - int displayNum = 0; - GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F); - float width = 0.0F; - if (completed < 0.5F && (displayNum == 1 || displayNum == 0)) { - width = (0.5F - completed) * xSize; - drawTexturedRect(x + xSize * completed, y, width, 5.0 |
