aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/rosegoldaddons/utils
diff options
context:
space:
mode:
authorRoseGoldIsntGay <yoavkau@gmail.com>2021-11-07 18:34:22 +0200
committerRoseGoldIsntGay <yoavkau@gmail.com>2021-11-07 18:34:22 +0200
commit6f69d1e1aff688bf2f5ca34754640eed5102b045 (patch)
treee931c56ad48dedb4cec6ffceb78ef0b320c1c192 /src/main/java/rosegoldaddons/utils
downloadRGA-6f69d1e1aff688bf2f5ca34754640eed5102b045.tar.gz
RGA-6f69d1e1aff688bf2f5ca34754640eed5102b045.tar.bz2
RGA-6f69d1e1aff688bf2f5ca34754640eed5102b045.zip
committed
or something
Diffstat (limited to 'src/main/java/rosegoldaddons/utils')
-rw-r--r--src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java154
-rw-r--r--src/main/java/rosegoldaddons/utils/OutlineUtils.java152
-rw-r--r--src/main/java/rosegoldaddons/utils/RenderUtils.java682
-rw-r--r--src/main/java/rosegoldaddons/utils/RotationUtils.java110
4 files changed, 1098 insertions, 0 deletions
diff --git a/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java
new file mode 100644
index 0000000..6eed707
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/OpenSkyblockGui.java
@@ -0,0 +1,154 @@
+package rosegoldaddons.utils;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.inventory.GuiChest;
+import net.minecraft.inventory.Container;
+import net.minecraft.inventory.ContainerChest;
+import net.minecraft.inventory.Slot;
+import net.minecraft.util.ChatComponentText;
+import net.minecraft.util.StringUtils;
+import net.minecraftforge.client.event.GuiScreenEvent;
+import net.minecraftforge.fml.common.eventhandler.SubscribeEvent;
+import rosegoldaddons.commands.Backpack;
+import rosegoldaddons.commands.LobbySwap;
+
+import java.util.List;
+
+public class OpenSkyblockGui {
+ int windowId;
+ boolean openingWardrobe = false;
+ boolean lobbySwapping = false;
+ boolean openingBP = false;
+
+ @SubscribeEvent
+ public void guiDraw(GuiScreenEvent.BackgroundDrawnEvent event) {
+ if (!rosegoldaddons.commands.Rosedrobe.openWardrobe || openingWardrobe) return;
+ new Thread(() -> {
+ try {
+ openingWardrobe = true;
+ if (event.gui instanceof GuiChest) {
+ Container container = ((GuiChest) event.gui).inventorySlots;
+ if (container instanceof ContainerChest) {
+ String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
+ List<Slot> invSlots = container.inventorySlots;
+ if (chestName.contains("Pets")) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ String slotName = StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName());
+ //Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(slotName));
+ if (slotName.equals("Go Back")) {
+ clickSlot(invSlots.get(i));
+ }
+ }
+ } else if (chestName.contains("SkyBlock")) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Wardrobe")) {
+ clickSlot(invSlots.get(i));
+ if (rosegoldaddons.commands.Rosedrobe.slot == 0)
+ rosegoldaddons.commands.Rosedrobe.openWardrobe = false;
+ }
+ }
+ } else if (chestName.contains("Wardrobe")) {
+ if (rosegoldaddons.commands.Rosedrobe.slot != 0) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ String slotName = "Slot " + rosegoldaddons.commands.Rosedrobe.slot + ":";
+ if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).contains(slotName)) {
+ clickSlot(invSlots.get(i));
+ Minecraft.getMinecraft().thePlayer.closeScreen();
+ rosegoldaddons.commands.Rosedrobe.openWardrobe = false;
+ }
+ }
+ }
+ }
+ }
+ }
+ openingWardrobe = false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+
+ @SubscribeEvent
+ public void guiDraw2(GuiScreenEvent.BackgroundDrawnEvent event) {
+ if (!LobbySwap.swapLobby || lobbySwapping) return;
+ new Thread(() -> {
+ try {
+ lobbySwapping = true;
+ if (event.gui instanceof GuiChest) {
+ Container container = ((GuiChest) event.gui).inventorySlots;
+ if (container instanceof ContainerChest) {
+ String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
+ List<Slot> invSlots = container.inventorySlots;
+ if (chestName.contains("SkyBlock")) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Enter the Crystal Hollows")) {
+ clickSlot(invSlots.get(i));
+ }
+ }
+ } else if (chestName.contains("Enter the")) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).equals("Confirm")) {
+ clickSlot(invSlots.get(i));
+ LobbySwap.swapLobby = false;
+ }
+ }
+ Thread.sleep(2000);
+ Minecraft.getMinecraft().thePlayer.addChatMessage(new ChatComponentText(Minecraft.getMinecraft().theWorld.getWorldTime() + " ticks"));
+ }
+ }
+ }
+ lobbySwapping = false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+
+ @SubscribeEvent
+ public void guiDraw3(GuiScreenEvent.BackgroundDrawnEvent event) {
+ if (!Backpack.openBP || openingBP) return;
+ new Thread(() -> {
+ try {
+ openingBP = true;
+ if (event.gui instanceof GuiChest) {
+ Container container = ((GuiChest) event.gui).inventorySlots;
+ if (container instanceof ContainerChest) {
+ String chestName = ((ContainerChest) container).getLowerChestInventory().getDisplayName().getUnformattedText();
+ List<Slot> invSlots = container.inventorySlots;
+ if (chestName.contains("Storage")) {
+ if (Backpack.bpSlot != 0) {
+ int i;
+ for (i = 0; i < invSlots.size(); i++) {
+ if (!invSlots.get(i).getHasStack()) continue;
+ String slotName = "Slot " + Backpack.bpSlot;
+ if (StringUtils.stripControlCodes(invSlots.get(i).getStack().getDisplayName()).contains(slotName)) {
+ clickSlot(invSlots.get(i));
+ Backpack.openBP = false;
+ }
+ }
+ }
+ }
+ }
+ }
+ openingBP = false;
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }).start();
+ }
+
+ private void clickSlot(Slot slot) {
+ windowId = Minecraft.getMinecraft().thePlayer.openContainer.windowId;
+ Minecraft.getMinecraft().playerController.windowClick(windowId, slot.slotNumber, 0, 0, Minecraft.getMinecraft().thePlayer);
+ }
+}
diff --git a/src/main/java/rosegoldaddons/utils/OutlineUtils.java b/src/main/java/rosegoldaddons/utils/OutlineUtils.java
new file mode 100644
index 0000000..0b1bde2
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/OutlineUtils.java
@@ -0,0 +1,152 @@
+package rosegoldaddons.utils;
+
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.model.ModelBase;
+import net.minecraft.client.renderer.GlStateManager;
+import net.minecraft.client.renderer.OpenGlHelper;
+import net.minecraft.client.shader.Framebuffer;
+import net.minecraft.entity.EntityLivingBase;
+import org.lwjgl.opengl.EXTFramebufferObject;
+import org.lwjgl.opengl.EXTPackedDepthStencil;
+import rosegoldaddons.events.RenderLivingEntityEvent;
+
+import java.awt.*;
+
+import static org.lwjgl.opengl.GL11.*;
+
+public class OutlineUtils {
+
+ public static void outlineESP(EntityLivingBase entity, float p_77036_2_, float p_77036_3_, float p_77036_4_, float p_77036_5_, float p_77036_6_, float scaleFactor, ModelBase modelBase, Color color) {
+ Minecraft mc = Minecraft.getMinecraft();
+ boolean fancyGraphics = mc.gameSettings.fancyGraphics;
+ float gamma = mc.gameSettings.gammaSetting;
+ mc.gameSettings.fancyGraphics = false;
+ mc.gameSettings.gammaSetting = 100000F;
+
+ GlStateManager.resetColor();
+ setColor(color);
+ renderOne(2);
+ modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
+ setColor(color);
+ renderTwo();
+ modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
+ setColor(color);
+ renderThree();
+ modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
+ setColor(color);
+ renderFour(color);
+ modelBase.render(entity, p_77036_2_, p_77036_3_, p_77036_4_, p_77036_5_, p_77036_6_, scaleFactor);
+ setColor(color);
+ renderFive();
+ setColor(Color.WHITE);
+
+ mc.gameSettings.fancyGraphics = fancyGraphics;
+ mc.gameSettings.gammaSetting = gamma;
+ }
+
+ public static void outlineESP(RenderLivingEntityEvent event, Color color) {
+ Minecraft mc = Minecraft.getMinecraft();
+ boolean fancyGraphics = mc.gameSettings.fancyGraphics;
+ float gamma = mc.gameSettings.gammaSetting;
+ mc.gameSettings.fancyGraphics = false;
+ mc.gameSettings.gammaSetting = 100000F;
+
+ GlStateManager.resetColor();
+ setColor(color);
+ renderOne(2);
+ event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
+ setColor(color);
+ renderTwo();
+ event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
+ setColor(color);
+ renderThree();
+ event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
+ setColor(color);
+ renderFour(color);
+ event.modelBase.render(event.entity, event.p_77036_2_, event.p_77036_3_, event.p_77036_4_, event.p_77036_5_, event.p_77036_6_, event.scaleFactor);
+ setColor(color);
+ renderFive();
+ setColor(Color.WHITE);
+
+ mc.gameSettings.fancyGraphics = fancyGraphics;
+ mc.gameSettings.gammaSetting = gamma;
+ }
+
+ public static void renderOne(final float lineWidth) {
+ checkSetupFBO();
+ glPushAttrib(GL_ALL_ATTRIB_BITS);
+ glDisable(GL_ALPHA_TEST);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_LIGHTING);
+ glEnable(GL_BLEND);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glLineWidth(lineWidth);
+ glEnable(GL_LINE_SMOOTH);
+ glEnable(GL_STENCIL_TEST);
+ glClear(GL_STENCIL_BUFFER_BIT);
+ glClearStencil(0xF);
+ glStencilFunc(GL_NEVER, 1, 0xF);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ }
+
+ public static void renderTwo() {
+ glStencilFunc(GL_NEVER, 0, 0xF);
+ glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
+ }
+
+ public static void renderThree() {
+ glStencilFunc(GL_EQUAL, 1, 0xF);
+ glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
+ glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
+ }
+
+ public static void renderFour(final Color color) {
+ setColor(color);
+ glDepthMask(false);
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_POLYGON_OFFSET_LINE);
+ glPolygonOffset(1.0F, -2000000F);
+ OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, 240.0F, 240.0F);
+ }
+
+ public static void renderFive() {
+ glPolygonOffset(1.0F, 2000000F);
+ glDisable(GL_POLYGON_OFFSET_LINE);
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(true);
+ glDisable(GL_STENCIL_TEST);
+ glDisable(GL_LINE_SMOOTH);
+ glHint(GL_LINE_SMOOTH_HINT, GL_DONT_CARE);
+ glEnable(GL_BLEND);
+ glEnable(GL_LIGHTING);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_ALPHA_TEST);
+ glPopAttrib();
+ }
+
+ public static void setColor(final Color color) {
+ glColor4d(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
+ }
+
+ public static void checkSetupFBO() {
+ final Framebuffer fbo = Minecraft.getMinecraft().getFramebuffer();
+ if (fbo != null) {
+ if (fbo.depthBuffer > -1) {
+ setupFBO(fbo);
+ fbo.depthBuffer = -1;
+ }
+ }
+ }
+
+ private static void setupFBO(final Framebuffer fbo) {
+ EXTFramebufferObject.glDeleteRenderbuffersEXT(fbo.depthBuffer);
+ final int stencil_depth_buffer_ID = EXTFramebufferObject.glGenRenderbuffersEXT();
+ EXTFramebufferObject.glBindRenderbufferEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
+ EXTFramebufferObject.glRenderbufferStorageEXT(EXTFramebufferObject.GL_RENDERBUFFER_EXT, EXTPackedDepthStencil.GL_DEPTH_STENCIL_EXT, Minecraft.getMinecraft().displayWidth, Minecraft.getMinecraft().displayHeight);
+ EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_STENCIL_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
+ EXTFramebufferObject.glFramebufferRenderbufferEXT(EXTFramebufferObject.GL_FRAMEBUFFER_EXT, EXTFramebufferObject.GL_DEPTH_ATTACHMENT_EXT, EXTFramebufferObject.GL_RENDERBUFFER_EXT, stencil_depth_buffer_ID);
+ }
+
+}
diff --git a/src/main/java/rosegoldaddons/utils/RenderUtils.java b/src/main/java/rosegoldaddons/utils/RenderUtils.java
new file mode 100644
index 0000000..5d3e2f2
--- /dev/null
+++ b/src/main/java/rosegoldaddons/utils/RenderUtils.java
@@ -0,0 +1,682 @@
+package rosegoldaddons.utils;
+
+import net.minecraft.block.Block;
+import net.minecraft.client.Minecraft;
+import net.minecraft.client.gui.ScaledResolution;
+import net.minecraft.client.renderer.GlStateManager;
+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.EntityLivingBase;
+import net.minecraft.entity.player.EntityPlayer;
+import net.minecraft.util.AxisAlignedBB;
+import net.minecraft.util.BlockPos;
+import net.minecraft.util.ResourceLocation;
+import org.lwjgl.opengl.GL11;
+import org.lwjgl.opengl.GL14;
+
+import java.awt.*;
+import java.util.HashMap;
+import java.util.Map;
+
+import static java.lang.Math.*;
+import static org.lwjgl.opengl.GL11.*;
+
+public class RenderUtils {
+
+ private static final Map<Integer, Boolean> glCapMap = new HashMap<>();
+ private static final int[] DISPLAY_LISTS_2D = new int[4];
+ private static final Minecraft mc = Minecraft.getMinecraft();
+
+ static {
+ for (int i = 0; i < DISPLAY_LISTS_2D.length; i++) {
+ DISPLAY_LISTS_2D[i] = glGenLists(1);
+ }
+
+ glNewList(DISPLAY_LISTS_2D[0], GL_COMPILE);
+
+ quickDrawRect(-7F, 2F, -4F, 3F);
+ quickDrawRect(4F, 2F, 7F, 3F);
+ quickDrawRect(-7F, 0.5F, -6F, 3F);
+ quickDrawRect(6F, 0.5F, 7F, 3F);
+
+ glEndList();
+
+ glNewList(DISPLAY_LISTS_2D[1], GL_COMPILE);
+
+ quickDrawRect(-7F, 3F, -4F, 3.3F);
+ quickDrawRect(4F, 3F, 7F, 3.3F);
+ quickDrawRect(-7.3F, 0.5F, -7F, 3.3F);
+ quickDrawRect(7F, 0.5F, 7.3F, 3.3F);
+
+ glEndList();
+
+ glNewList(DISPLAY_LISTS_2D[2], GL_COMPILE);
+
+ quickDrawRect(4F, -20F, 7F, -19F);
+ quickDrawRect(-7F, -20F, -4F, -19F);
+ quickDrawRect(6F, -20F, 7F, -17.5F);
+ quickDrawRect(-7F, -20F, -6F, -17.5F);
+
+ glEndList();
+
+ glNewList(DISPLAY_LISTS_2D[3], GL_COMPILE);
+
+ quickDrawRect(7F, -20F, 7.3F, -17.5F);
+ quickDrawRect(-7.3F, -20F, -7F, -17.5F);
+ quickDrawRect(4F, -20.3F, 7.3F, -20F);
+ quickDrawRect(-7.3F, -20.3F, -4F, -20F);
+
+ glEndList();
+ }
+
+ public static void drawBlockBox(final BlockPos blockPos, final Color color, final boolean outline, float partialTicks) {
+ final RenderManager renderManager = mc.getRenderManager();
+
+ final double x = blockPos.getX() - renderManager.viewerPosX;
+ final double y = blockPos.getY() - renderManager.viewerPosY;
+ final double z = blockPos.getZ() - renderManager.viewerPosZ;
+
+ AxisAlignedBB axisAlignedBB = new AxisAlignedBB(x, y, z, x + 1.0, y + 1.0, z + 1.0);
+ final Block block = mc.theWorld.getBlockState(blockPos).getBlock();
+
+ if (block != null) {
+ final EntityPlayer player = mc.thePlayer;
+
+ final double posX = player.lastTickPosX + (player.posX - player.lastTickPosX) * partialTicks;
+ final double posY = player.lastTickPosY + (player.posY - player.lastTickPosY) * partialTicks;
+ final double posZ = player.lastTickPosZ + (player.posZ - player.lastTickPosZ) * partialTicks;
+
+ block.setBlockBoundsBasedOnState(mc.theWorld, blockPos);
+
+ axisAlignedBB = block.getSelectedBoundingBox(mc.theWorld, blockPos)
+ .expand(0.0020000000949949026D, 0.0020000000949949026D, 0.0020000000949949026D)
+ .offset(-posX, -posY, -posZ);
+ }
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ enableGlCap(GL_BLEND);
+ disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST);
+ glDepthMask(false);
+
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha() != 255 ? color.getAlpha() : outline ? 26 : 35);
+ drawFilledBox(axisAlignedBB);
+
+ if (outline) {
+ glLineWidth(1F);
+ enableGlCap(GL_LINE_SMOOTH);
+ glColor(color);
+
+ drawSelectionBoundingBox(axisAlignedBB);
+ }
+
+ GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glDepthMask(true);
+ resetCaps();
+ }
+
+ public static void drawSelectionBoundingBox(AxisAlignedBB boundingBox) {
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+
+ worldrenderer.begin(GL_LINE_STRIP, DefaultVertexFormats.POSITION);
+
+ // Lower Rectangle
+ worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex();
+ worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex();
+ worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.minZ).endVertex();
+
+ // Upper Rectangle
+ worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex();
+ worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex();
+ worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.minZ).endVertex();
+
+ // Upper Rectangle
+ worldrenderer.pos(boundingBox.minX, boundingBox.maxY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.minX, boundingBox.minY, boundingBox.maxZ).endVertex();
+
+ worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.maxZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.maxZ).endVertex();
+
+ worldrenderer.pos(boundingBox.maxX, boundingBox.maxY, boundingBox.minZ).endVertex();
+ worldrenderer.pos(boundingBox.maxX, boundingBox.minY, boundingBox.minZ).endVertex();
+
+ tessellator.draw();
+ }
+
+ public static void drawEntityBox(final Entity entity, final Color color, final boolean outline, float partialTicks) {
+ final RenderManager renderManager = mc.getRenderManager();
+
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ enableGlCap(GL_BLEND);
+ disableGlCap(GL_TEXTURE_2D, GL_DEPTH_TEST);
+ glDepthMask(false);
+
+ final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks
+ - renderManager.viewerPosX;
+ final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks
+ - renderManager.viewerPosY;
+ final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks
+ - renderManager.viewerPosZ;
+
+ final AxisAlignedBB entityBox = entity.getEntityBoundingBox();
+ final AxisAlignedBB axisAlignedBB = new AxisAlignedBB(
+ entityBox.minX - entity.posX + x - 0.05D,
+ entityBox.minY - entity.posY + y,
+ entityBox.minZ - entity.posZ + z - 0.05D,
+ entityBox.maxX - entity.posX + x + 0.05D,
+ entityBox.maxY - entity.posY + y + 0.15D,
+ entityBox.maxZ - entity.posZ + z + 0.05D
+ );
+
+ if (outline) {
+ glLineWidth(1F);
+ enableGlCap(GL_LINE_SMOOTH);
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), 95);
+ drawSelectionBoundingBox(axisAlignedBB);
+ }
+
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), outline ? 26 : 35);
+ drawFilledBox(axisAlignedBB);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glDepthMask(true);
+ resetCaps();
+ }
+
+ public static void drawAxisAlignedBB(final AxisAlignedBB axisAlignedBB, final Color color) {
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_BLEND);
+ glLineWidth(2F);
+ glDisable(GL_TEXTURE_2D);
+ glDisable(GL_DEPTH_TEST);
+ glDepthMask(false);
+ glColor(color);
+ drawFilledBox(axisAlignedBB);
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+ glEnable(GL_TEXTURE_2D);
+ glEnable(GL_DEPTH_TEST);
+ glDepthMask(true);
+ glDisable(GL_BLEND);
+ }
+
+ public static void drawPlatform(final double y, final Color color, final double size) {
+ final RenderManager renderManager = mc.getRenderManager();
+ final double renderY = y - renderManager.viewerPosY;
+
+ drawAxisAlignedBB(new AxisAlignedBB(size, renderY + 0.02D, size, -size, renderY, -size), color);
+ }
+
+ public static void drawPlatform(final Entity entity, final Color color, float partialTicks) {
+ final RenderManager renderManager = mc.getRenderManager();
+
+ final double x = entity.lastTickPosX + (entity.posX - entity.lastTickPosX) * partialTicks
+ - renderManager.viewerPosX;
+ final double y = entity.lastTickPosY + (entity.posY - entity.lastTickPosY) * partialTicks
+ - renderManager.viewerPosY;
+ final double z = entity.lastTickPosZ + (entity.posZ - entity.lastTickPosZ) * partialTicks
+ - renderManager.viewerPosZ;
+
+ final AxisAlignedBB axisAlignedBB = entity.getEntityBoundingBox()
+ .offset(-entity.posX, -entity.posY, -entity.posZ)
+ .offset(x, y, z);
+
+ drawAxisAlignedBB(
+ new AxisAlignedBB(axisAlignedBB.minX, axisAlignedBB.maxY + 0.2, axisAlignedBB.minZ, axisAlignedBB.maxX, axisAlignedBB.maxY + 0.26, axisAlignedBB.maxZ),
+ color
+ );
+ }
+
+ public static void drawFilledBox(final AxisAlignedBB axisAlignedBB) {
+ final Tessellator tessellator = Tessellator.getInstance();
+ final WorldRenderer worldRenderer = tessellator.getWorldRenderer();
+
+ worldRenderer.begin(7, DefaultVertexFormats.POSITION);
+
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.minX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.minZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.maxY, axisAlignedBB.maxZ).endVertex();
+ worldRenderer.pos(axisAlignedBB.maxX, axisAlignedBB.minY, axisAlignedBB.maxZ).endVertex();
+ tessellator.draw();
+ }
+
+ public static void quickDrawRect(final float x, final float y, final float x2, final float y2) {
+ glBegin(GL_QUADS);
+
+ glVertex2d(x2, y);
+ glVertex2d(x, y);
+ glVertex2d(x, y2);
+ glVertex2d(x2, y2);
+
+ glEnd();
+ }
+
+ public static void drawRect(final float x, final float y, final float x2, final float y2, final int color) {
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+
+ glColor(color);
+ glBegin(GL_QUADS);
+
+ glVertex2f(x2, y);
+ glVertex2f(x, y);
+ glVertex2f(x, y2);
+ glVertex2f(x2, y2);
+ glEnd();
+
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+
+ public static void drawRect(final int x, final int y, final int x2, final int y2, final int color) {
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+
+ glColor(color);
+ glBegin(GL_QUADS);
+
+ glVertex2i(x2, y);
+ glVertex2i(x, y);
+ glVertex2i(x, y2);
+ glVertex2i(x2, y2);
+ glEnd();
+
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+
+ /**
+ * Like {@link #drawRect(float, float, float, float, int)}, but without setup
+ */
+ public static void quickDrawRect(final float x, final float y, final float x2, final float y2, final int color) {
+ glColor(color);
+ glBegin(GL_QUADS);
+
+ glVertex2d(x2, y);
+ glVertex2d(x, y);
+ glVertex2d(x, y2);
+ glVertex2d(x2, y2);
+
+ glEnd();
+ }
+
+ public static void drawRect(final float x, final float y, final float x2, final float y2, final Color color) {
+ drawRect(x, y, x2, y2, color.getRGB());
+ }
+
+ public static void drawBorderedRect(final float x, final float y, final float x2, final float y2, final float width,
+ final int color1, final int color2) {
+ drawRect(x, y, x2, y2, color2);
+ drawBorder(x, y, x2, y2, width, color1);
+ }
+
+ public static void drawBorder(float x, float y, float x2, float y2, float width, int color1) {
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+
+ glColor(color1);
+ glLineWidth(width);
+
+ glBegin(GL_LINE_LOOP);
+
+ glVertex2d(x2, y);
+ glVertex2d(x, y);
+ glVertex2d(x, y2);
+ glVertex2d(x2, y2);
+
+ glEnd();
+
+ glEnable(GL_TEXTURE_2D);
+ glDisable(GL_BLEND);
+ glDisable(GL_LINE_SMOOTH);
+ }
+
+ public static void quickDrawBorderedRect(final float x, final float y, final float x2, final float y2, final float width, final int color1, final int color2) {
+ quickDrawRect(x, y, x2, y2, color2);
+
+ glColor(color1);
+ glLineWidth(width);
+
+ glBegin(GL_LINE_LOOP);
+
+ glVertex2d(x2, y);
+ glVertex2d(x, y);
+ glVertex2d(x, y2);
+ glVertex2d(x2, y2);
+
+ glEnd();
+ }
+
+ public static void drawLoadingCircle(float x, float y) {
+ for (int i = 0; i < 4; i++) {
+ int rot = (int) ((System.nanoTime() / 5000000 * i) % 360);
+ drawCircle(x, y, i * 10, rot - 180, rot);
+ }
+ }
+
+ public static void drawCircle(float x, float y, float radius, int start, int end) {
+ GlStateManager.enableBlend();
+ GlStateManager.disableTexture2D();
+ GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
+ glColor(Color.WHITE);
+
+ glEnable(GL_LINE_SMOOTH);
+ glLineWidth(2F);
+ glBegin(GL_LINE_STRIP);
+ for (float i = end; i >= start; i -= (360 / 90.0f)) {
+ glVertex2f((float) (x + (cos(i * PI / 180) * (radius * 1.001F))), (float) (y + (sin(i * PI / 180) * (radius * 1.001F))));
+ }
+ glEnd();
+ glDisable(GL_LINE_SMOOTH);
+
+ GlStateManager.enableTexture2D();
+ GlStateManager.disableBlend();
+ }
+
+ public static void drawFilledCircle(final int xx, final int yy, final float radius, final Color color) {
+ int sections = 50;
+ double dAngle = 2 * Math.PI / sections;
+ float x, y;
+
+ glPushAttrib(GL_ENABLE_BIT);
+
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+ glEnable(GL_LINE_SMOOTH);
+ glBegin(GL_TRIANGLE_FAN);
+
+ for (int i = 0; i < sections; i++) {
+ x = (float) (radius * Math.sin((i * dAngle)));
+ y = (float) (radius * Math.cos((i * dAngle)));
+
+ glColor4f(color.getRed() / 255F, color.getGreen() / 255F, color.getBlue() / 255F, color.getAlpha() / 255F);
+ glVertex2f(xx + x, yy + y);
+ }
+
+ glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
+
+ glEnd();
+
+ glPopAttrib();
+ }
+
+ public static void drawImage(ResourceLocation image, int x, int y, int width, int height) {
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ glDepthMask(false);
+ GL14.glBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_ONE, GL_ZERO);
+ glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
+ mc.getTextureManager().bindTexture(image);
+ drawModalRectWithCustomSizedTexture(x, y, 0, 0, width, height, width, height);
+ glDepthMask(true);
+ glDisable(GL_BLEND);
+ glEnable(GL_DEPTH_TEST);
+ }
+
+ /**
+ * Draws a textured rectangle at z = 0. Args: x, y, u, v, width, height, textureWidth, textureHeight
+ */
+ public static void drawModalRectWithCustomSizedTexture(float x, float y, float u, float v, float width, float height, float textureWidth, float textureHeight) {
+ float f = 1.0F / textureWidth;
+ float f1 = 1.0F / textureHeight;
+ Tessellator tessellator = Tessellator.getInstance();
+ WorldRenderer worldrenderer = tessellator.getWorldRenderer();
+ worldrenderer.begin(7, DefaultVertexFormats.POSITION);
+ worldrenderer.pos(x, y + height, 0.0D).tex(u * f, (v + height) * f1).endVertex();
+ worldrenderer.pos(x + width, y + height, 0.0D).tex((u + width) * f, (v + height) * f1).endVertex();
+ worldrenderer.pos(x + width, y, 0.0D).tex((u + width) * f, v * f1).endVertex();
+ worldrenderer.pos(x, y, 0.0D).tex(u * f, v * f1).endVertex();
+ tessellator.draw();
+ }
+
+ public static void glColor(final int red, final int green, final int blue, final int alpha) {
+ GL11.glColor4f(red / 255F, green / 255F, blue / 255F, alpha / 255F);
+ }
+
+ public static void glColor(final Color color) {
+ glColor(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());
+ }
+
+ private static void glColor(final int hex) {
+ glColor(hex >> 16 & 0xFF, hex >> 8 & 0xFF, hex & 0xFF, hex >> 24 & 0xFF);
+ }
+
+ public static void draw2D(final EntityLivingBase entity, final double posX, final double posY, final double posZ, final int color, final int backgroundColor) {
+ GL11.glPushMatrix();
+ GL11.glTranslated(posX, posY, posZ);
+ GL11.glRotated(-mc.getRenderManager().viewerPosY, 0F, 1F, 0F);
+ GL11.glScaled(-0.1D, -0.1D, 0.1D);
+
+ glDisable(GL_DEPTH_TEST);
+ glEnable(GL_BLEND);
+ glDisable(GL_TEXTURE_2D);
+ glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
+