diff options
author | syeyoung <cyong06@naver.com> | 2021-04-25 22:50:30 +0900 |
---|---|---|
committer | syeyoung <cyong06@naver.com> | 2021-04-25 22:50:30 +0900 |
commit | 01d7e03fd68d28059d90496123b010182657feab (patch) | |
tree | c4ce916b24d939e1f960ff7ab4501c45adb4fbd8 /src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java | |
parent | f54b267b337dee36fc9997abd1193393db11878e (diff) | |
download | Skyblock-Dungeons-Guide-01d7e03fd68d28059d90496123b010182657feab.tar.gz Skyblock-Dungeons-Guide-01d7e03fd68d28059d90496123b010182657feab.tar.bz2 Skyblock-Dungeons-Guide-01d7e03fd68d28059d90496123b010182657feab.zip |
yes.
Diffstat (limited to 'src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java')
-rwxr-xr-x | src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java | 57 |
1 files changed, 53 insertions, 4 deletions
diff --git a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java index b2722e77..72f5f793 100755 --- a/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java +++ b/src/main/java/kr/syeyoung/dungeonsguide/utils/RenderUtils.java @@ -14,10 +14,7 @@ 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.AxisAlignedBB; -import net.minecraft.util.BlockPos; -import net.minecraft.util.Vec3; -import net.minecraft.util.Vector3d; +import net.minecraft.util.*; import org.lwjgl.opengl.GL11; import javax.vecmath.Vector3f; @@ -25,6 +22,58 @@ import java.awt.*; import java.util.List; public class RenderUtils { + public static final ResourceLocation icons = new ResourceLocation("textures/gui/icons.png"); + + 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); + } + 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((double)x, (double)(y + height), 0.0D).tex((double)uMin, (double)vMax).endVertex(); + worldrenderer.pos((double)(x + width), (double)(y + height), 0.0D).tex((double)uMax, (double)vMax).endVertex(); + worldrenderer.pos((double)(x + width), (double)y, 0.0D).tex((double)uMax, (double)vMin).endVertex(); + worldrenderer.pos((double)x, (double)y, 0.0D).tex((double)uMin, (double)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.0F, xSize * completed / 256.0F, xSize / 2.0F / 256.0F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed < 1.0F && (displayNum == 2 || displayNum == 0)) { + width = Math.min(xSize * notcompleted, xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F), y, width, 5.0F, (182.0F - xSize / 2.0F + Math.max(xSize * (completed - 0.5F), 0.0F)) / 256.0F, 0.7109375F, 0.2890625F, 0.30859375F, 9728); + } + + if (completed > 0.0F && (displayNum == 3 || displayNum == 0)) { + width = Math.min(xSize * completed, xSize / 2.0F); + drawTexturedRect(x, y, width, 5.0F, 0.0F, width / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + if (completed > 0.5F && (displayNum == 4 || displayNum == 0)) { + width = Math.min(xSize * (completed - 0.5F), xSize / 2.0F); + drawTexturedRect(x + xSize / 2.0F, y, width, 5.0F, (182.0F - xSize / 2.0F) / 256.0F, (182.0F - xSize / 2.0F + width) / 256.0F, 0.30859375F, 0.328125F, 9728); + } + + } + public static void drawUnfilledBox(int left, int top, int right, int bottom, int color, boolean chroma) { if (left < right) |