Created
December 7, 2013 03:45
-
-
Save Jezza/7837044 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void drawTextInAir(double x, double y, double z, double partialTicks, String text) { | |
| if ((Minecraft.getMinecraft().renderViewEntity instanceof EntityPlayer)) { | |
| EntityPlayer player = (EntityPlayer) Minecraft.getMinecraft().renderViewEntity; | |
| double iPX = player.prevPosX + (player.posX - player.prevPosX) * partialTicks; | |
| double iPY = player.prevPosY + (player.posY - player.prevPosY) * partialTicks; | |
| double iPZ = player.prevPosZ + (player.posZ - player.prevPosZ) * partialTicks; | |
| GL11.glPushMatrix(); | |
| GL11.glTranslated(-iPX + x + 0.5D, -iPY + y + 1.5D, -iPZ + z + 0.5D); | |
| float xd = (float) (iPX - (x + 0.5D)); | |
| float zd = (float) (iPZ - (z + 0.5D)); | |
| float rotYaw = (float) (Math.atan2(xd, zd) * 180.0D / 3.141592653589793D); | |
| GL11.glRotatef(rotYaw + 180.0F, 0.0F, 1.0F, 0.0F); | |
| GL11.glRotatef(180.0F, 0.0F, 0.0F, 1.0F); | |
| GL11.glScalef(0.02F, 0.02F, 0.02F); | |
| int sw = Minecraft.getMinecraft().fontRenderer.getStringWidth(text); | |
| GL11.glEnable(3042); | |
| Minecraft.getMinecraft().fontRenderer.drawString(text, 1 - sw / 2, 1, 1118481); | |
| GL11.glTranslated(0.0D, 0.0D, -0.1D); | |
| Minecraft.getMinecraft().fontRenderer.drawString(text, -sw / 2, 0, 16777215); | |
| GL11.glDisable(3042); | |
| GL11.glPopMatrix(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment