Posted January 20, 201510 yr I was wondering if there was a way to change the in-game cursor and if so how would I go about doing this
January 20, 201510 yr Just want to reassure - cursor or crosshair? Crosshair is derived from Gui.icons (texturepack) and rendered using GuiIngame (you can cancel it with events). As to cursor - that's strictly Java stuff and operating on Frame stuff. You would need to edit something at very-beggining of launching client. Since windows-cursor is rendered over the application using events to render custom cursor will leave you with 2 cursors on top of each other (windows one on top). I guess you could try accessing it somehow during game rendering, but I have no idea how you would do it smart way (mainly because I don't know what MC uses to build program frame). 1.7.10 is no longer supported by forge, you are on your own.
January 20, 201510 yr Hi The RenderGameOverlayEvent.Pre is your friend. /** * Draw the custom crosshairs if reqd * Otherwise, cancel the event so that the normal crosshair is drawn. * @param event */ @SubscribeEvent public void renderOverlayPre(RenderGameOverlayEvent.Pre event) { if (event.type == RenderGameOverlayEvent.ElementType.CROSSHAIRS) { ClientSide.speedyToolRenderers.render(renderGameOverlayCrosshairsEvent, event.partialTicks); event.setCanceled(renderGameOverlayCrosshairsEvent.isCanceled()); } return; } You will also need to know - - how to subscribe your eventhandler to the event bus, http://www.wuppy29.com/minecraft/modding-tutorials/wuppys-minecraft-forge-modding-tutorials-for-1-7-events and how to use OpenGL to draw your custom cursor directly to the screen. (This is trickier. The fragment below might give you some clues. Let us know if you need more guidance.) -TGG ScaledResolution scaledResolution = event.resolution; int width = scaledResolution.getScaledWidth(); int height = scaledResolution.getScaledHeight(); final float Z_LEVEL_FROM_GUI_IN_GAME_FORGE = -90.0F; // taken from GuiInGameForge.renderCrossHairs final double CROSSHAIR_ICON_WIDTH = 88; final double CROSSHAIR_ICON_HEIGHT = 88; final double CROSSHAIR_ICON_RADIUS = 40; final double CROSSHAIR_X_OFFSET = -CROSSHAIR_ICON_WIDTH / 2.0; final double CROSSHAIR_Y_OFFSET = -CROSSHAIR_ICON_HEIGHT / 2.0; try { GL11.glPushAttrib(GL11.GL_ENABLE_BIT); GL11.glEnable(GL11.GL_BLEND); GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA); GL11.glColor3d(lineColour.R * ringColourIntensity, lineColour.G * ringColourIntensity, lineColour.B * ringColourIntensity); Minecraft.getMinecraft().renderEngine.bindTexture(ringTexture); GL11.glPushMatrix(); GL11.glTranslatef(width / 2, height / 2, Z_LEVEL_FROM_GUI_IN_GAME_FORGE); drawTexturedRectangle(CROSSHAIR_X_OFFSET * starSize * ringSize, CROSSHAIR_Y_OFFSET * starSize * ringSize, Z_LEVEL_FROM_GUI_IN_GAME_FORGE, CROSSHAIR_ICON_WIDTH * starSize * ringSize, CROSSHAIR_ICON_HEIGHT * starSize * ringSize); GL11.glPopMatrix(); GL11.glColor3d(lineColour.R * starColourIntensity, lineColour.G * starColourIntensity, lineColour.B * starColourIntensity); Minecraft.getMinecraft().renderEngine.bindTexture(octoStarTexture); GL11.glPushMatrix(); GL11.glTranslatef(width / 2, height / 2, Z_LEVEL_FROM_GUI_IN_GAME_FORGE); GL11.glRotated( (clockwiseRotation ? degreesOfRotation : - degreesOfRotation), 0, 0, 1.0F); drawTexturedRectangle(CROSSHAIR_X_OFFSET * starSize, CROSSHAIR_Y_OFFSET * starSize, Z_LEVEL_FROM_GUI_IN_GAME_FORGE, CROSSHAIR_ICON_WIDTH * starSize, CROSSHAIR_ICON_HEIGHT * starSize); GL11.glPopMatrix(); final float ARC_LINE_WIDTH = 4.0F; if (drawTaskCompletionRing) { double progressBarIntensity = RING_COLOUR_MAX_INTENSITY; GL11.glColor3d(lineColour.R * progressBarIntensity, lineColour.G * progressBarIntensity, lineColour.B * progressBarIntensity); GL11.glDisable(GL11.GL_TEXTURE_2D); GL11.glPushMatrix(); GL11.glLineWidth(ARC_LINE_WIDTH); GL11.glTranslatef(width / 2, height / 2, Z_LEVEL_FROM_GUI_IN_GAME_FORGE); drawArc(CROSSHAIR_ICON_RADIUS * ringSize, 0.0, clockwiseRotation ? taskCompletionRingAngle : 360.0 - taskCompletionRingAngle, 0.0 ); GL11.glPopMatrix(); } } finally { GL11.glPopAttrib(); } and /** * Draws a textured rectangle at the given z-value, using the entire texture. Args: x, y, z, width, height */ private void drawTexturedRectangle(double x, double y, double z, double width, double height) { double ICON_MIN_U = 0.0; double ICON_MAX_U = 1.0; double ICON_MIN_V = 0.0; double ICON_MAX_V = 1.0; Tessellator tessellator = Tessellator.instance; tessellator.startDrawingQuads(); tessellator.addVertexWithUV( x + 0, y + height, z, ICON_MIN_U, ICON_MAX_V); tessellator.addVertexWithUV(x + width, y + height, z, ICON_MAX_U, ICON_MAX_V); tessellator.addVertexWithUV(x + width, y + 0, z, ICON_MAX_U, ICON_MIN_V); tessellator.addVertexWithUV( x + 0, y + 0, z, ICON_MIN_U, ICON_MIN_V); tessellator.draw(); }
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.