Jump to content

504185787

Members
  • Posts

    7
  • Joined

  • Last visited

Everything posted by 504185787

  1. Thanks. I found a class called ServerScoreboard - i'll check it out.
  2. I would like to display information to the player (server-side only) that is always on the screen. Here is an example of what I am talking about: This is done without any client-side mods. What is the side display called?
  3. @TheGreyGhost: Thanks. Got it working. That was the technique I was thinking about in my last post that Render#renderLivingLabel uses. Scaling is kind of annoying when doing it this way though. Have to scale with distance and set a min/max scale value. With the other method the text is always the same size regardless of distance.
  4. @TheGreyGhost: Thanks the inventory textures are now being rendered again. The underflow/overflow also seems to be fixed. objectMouseOver.entityHit ("Picking" / "ray cast") is the opposite of what I want. I don't need to get the entity. I already have it. I want the 2D point on the screen where that entity is so that I can draw text on it. I haven't done it with OpenGL before, only directX. I could also do it by disabling depth testing and drawing I believe. I'll see if I can get that to work.
  5. Right, but as I said in my post I don't see any push without a corresponding pop. Two pushMatrix, two popMatrix, one pushAttrib, one popAttrib. The text should overlay the 3d point. If the camera turns then the text should move as well and stay on that 3d point. For example: If the 3d point is the coordinates of a pig then the text should always be drawn on the pig.
  6. I'm having an issue with getting the correct screen coordinates. Also the inventory textures are not getting rendered. Which makes me think I'm not restoring the the state properly. I have also underflowed and overflowed the stack. I don't see how. For every push I have a corresponding pop. EntityRenderer#setupCameraTransform doesn't seem to push/pop anything either. Can someone take a look and tell me what I am doing wrong? I'm hooking RenderGameOverlay which seems like the right place for 2D rendering. However the matrices at this point aren't setup properly (not relative to camera) for gluProject. I first backup the matrices and other state information (current matrix mode) with GL11#glPushMatrix/glPushAttrib. Then I update the matrices (make them relative to camera) for gluProject by calling EntityRenderer#setupCameraTransform, store them in a buffer, and restore state. package org.504185787.test; import java.lang.reflect.Method; import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.Project; import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.EntityRenderer; import net.minecraft.client.renderer.GlStateManager; import net.minecraftforge.client.event.RenderGameOverlayEvent; import net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.fml.common.Mod; import net.minecraftforge.fml.common.Mod.EventHandler; import net.minecraftforge.fml.common.event.FMLPostInitializationEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; @Mod(modid = "testmod", name = "Test Mod", version = "0") public class TestMod { private Minecraft mc; @EventHandler public void postInit(FMLPostInitializationEvent event) { MinecraftForge.EVENT_BUS.register(this); mc = Minecraft.getMinecraft(); } @SubscribeEvent(priority = EventPriority.NORMAL) public void RenderGameOverlay(RenderGameOverlayEvent event) { if(!event.isCancelable() && event.type == ElementType.ALL) { GL11.glPushAttrib(GL11.GL_TRANSFORM_BIT); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPushMatrix(); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPushMatrix(); try { Method setupCameraTransform = EntityRenderer.class.getDeclaredMethod("setupCameraTransform", float.class, int.class); setupCameraTransform.setAccessible(true); setupCameraTransform.invoke(mc.entityRenderer, event.partialTicks, 0); } catch (Exception e) { e.printStackTrace(); } FloatBuffer modelMatrix = BufferUtils.createFloatBuffer(16); GL11.glGetFloat(GL11.GL_MODELVIEW_MATRIX, modelMatrix); FloatBuffer projMatrix = BufferUtils.createFloatBuffer(16); GL11.glGetFloat(GL11.GL_PROJECTION_MATRIX, projMatrix); IntBuffer viewport = BufferUtils.createIntBuffer(16); GL11.glGetInteger(GL11.GL_VIEWPORT, viewport); GL11.glMatrixMode(GL11.GL_MODELVIEW); GL11.glPopMatrix(); GL11.glMatrixMode(GL11.GL_PROJECTION); GL11.glPopMatrix(); GL11.glPopAttrib(); FloatBuffer screen2D = BufferUtils.createFloatBuffer(16); if(Project.gluProject(242, 76, 25, modelMatrix, projMatrix, viewport, screen2D)) { int[] screen = new int[] {(int)screen2D.get(0), (int)screen2D.get(1)}; mc.ingameGUI.drawString(mc.fontRendererObj, "Text", screen[0], screen[1], 0xFF00FF00); } mc.ingameGUI.drawString(mc.fontRendererObj, "[RenderGameOverlay]", 5, 5, 0xFF00FF00); } } }
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.