private void drawLeftHud() { GuiIngame gui = mc.ingameGUI; gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "FPS" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + String.valueOf(mc.getDebugFPS()), 2, 2, 14737632); gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "X" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + String.valueOf((int) mc.thePlayer.posX), 2, 17, 14737632); gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "Y" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + String.valueOf((int) mc.thePlayer.posY), 2, 27, 14737632); gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "Z" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + String.valueOf((int) mc.thePlayer.posZ), 2, 37, 14737632); gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "Facing" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + mc.thePlayer.getHorizontalFacing(), 2, 52, 14737632); gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "Clicks" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + ClickCounterChecker.getClickToDisplay(), 2, 67, 14737632); if (!mc.isSingleplayer()) { gui.drawString(mc.fontRendererObj, EnumChatFormatting.GRAY + "[" + EnumChatFormatting.GOLD + "Ping" + EnumChatFormatting.GRAY + "] " + EnumChatFormatting.RESET + getPingInformation(), 2, 82, 14737632); } }
@EventHandler public void init(final FMLInitializationEvent e) { FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); overrideExemptions.add(GuiIngame.class); try { mouseReadBuffer = mouseClass.getDeclaredField("readBuffer"); keyboardReadBuffer = keyboardClass.getDeclaredField("readBuffer"); mouseDWheel = mouseClass.getDeclaredField("dwheel"); mouseReadBuffer.setAccessible(true); keyboardReadBuffer.setAccessible(true); mouseDWheel.setAccessible(true); } catch (NoSuchFieldException e1) { e1.printStackTrace(); } catch (SecurityException ex) { if (System.getSecurityManager() == null) { GlassPaneMod.inst .getLog() .error("[GlassPane] [EventSystem] A SecurityException was thrown, but there's no SecurityManager registered..."); } else throw new PaneCantContinueError("Security manager (" + System.getSecurityManager().getClass().getName() + ") prevents proper collection of input events by GlassPane!", ex); } }
/** * Makes this GlassPane automatically get pushed onto the overlay stack when any screen of the passed type is shown.<br/> * Works for GuiScreens or GlassPanes. Object can also be passed to overlay any and every screen, no matter it's type. GuiIngame can be * passed to overlay the ingame GUI. * * @param screenOrPane * The class of the GUI to overlay. * @throws IllegalArgumentException * If screenOrPane is not of a supported type. */ public final void autoOverlay(final Class<?> screenOrPane) { // do we support the passed object? this is to prevent people from overlaying random garbage if (GlassPane.class.isAssignableFrom(screenOrPane) || GuiScreen.class.isAssignableFrom(screenOrPane) || GuiIngame.class.isAssignableFrom(screenOrPane) || screenOrPane == Object.class) { // fetch the list for this specific class List<GlassPane> list; if (GlassPaneMod.inst.overlays.containsKey(screenOrPane) && GlassPaneMod.inst.overlays.get(screenOrPane) != null) { // if we already have a list, we'll use it list = GlassPaneMod.inst.overlays.get(screenOrPane); } else { // otherwise make a new one list = Lists.newArrayList(); GlassPaneMod.inst.overlays.put(screenOrPane, list); } // add us to the list list.add(this); } else throw new IllegalArgumentException(screenOrPane.getName() + " is not supported by autoOverlay!"); }
private void onRenderTick() { Minecraft mc = Minecraft.getMinecraft(); int xSize = 124; int ySize = 13; final ResourceLocation mpbar = new ResourceLocation("kk", "textures/gui/MPBar.png"); if (mc.currentScreen == null) { GuiIngame gui = mc.ingameGUI; GL11.glPushMatrix(); Minecraft.getMinecraft().renderEngine.bindTexture(mpbar); GL11.glScalef(0.75f, 0.75f, 0.75f); gui.drawTexturedModalRect(0, 0, 0, 0, 124, 13); gui.drawTexturedModalRect(0, 0, 102 - (int)SummonEventHandler.barPercent, 13, 124, 13); GL11.glPopMatrix(); } }
@SideOnly(Side.CLIENT) @SubscribeEvent public void onRenderOverlayPostEvent(RenderGameOverlayEvent.Post event) { if (event.getType() == ElementType.ALL) { Minecraft minecraft = Minecraft.getMinecraft(); EntityPlayer player = minecraft.player; if (player.getHeldItem(EnumHand.OFF_HAND).getItem() instanceof IInfernalPowerItem) { int maxPower = player.getHeldItem(EnumHand.OFF_HAND).getMaxDamage(); int power = maxPower - player.getHeldItem(EnumHand.OFF_HAND).getItemDamage(); int width = event.getResolution().getScaledWidth(); int height = event.getResolution().getScaledHeight(); GuiIngame gui = Minecraft.getMinecraft().ingameGUI; Minecraft.getMinecraft().getTextureManager().bindTexture(HUD_TEXTURE); GlStateManager.enableBlend(); int y = (height / 2) - (42 / 2); int x = 3; int barHeight = (int) (((float) power / (float) maxPower) * 32); gui.drawTexturedModalRect(x, y, 0, 0, 10, 42); gui.drawTexturedModalRect(x + 1, y + 5 + (32 - barHeight), 10, 5, 8, barHeight); Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.ICONS); GlStateManager.disableBlend(); } } }
@Override @SideOnly(Side.CLIENT) public void renderCD(int x, int y, int w, int h) { int num = getNumber(); GuiIngame gui = Minecraft.getMinecraft().ingameGUI; FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; String text = String.valueOf(num); glScalef(FONT_SIZE, FONT_SIZE, 1F); gui.drawString(renderer, text, (x + w - renderer.getStringWidth(text) * FONT_SIZE - 3) / FONT_SIZE, (y + h - renderer.FONT_HEIGHT * FONT_SIZE - 3) / FONT_SIZE, 0xFF000000); glScalef(1F / FONT_SIZE, 1F / FONT_SIZE, 1F); }
@Override public void init() { //new PaneVanityArmor().autoOverlay(GuiInventory.class); //new PaneToolsOverlay().autoOverlay(GuiMainMenu.class); new PaneOrbGlow().autoOverlay(GuiIngame.class); if (FarragoMod.showBrand && StringUtils.isNotBlank(FarragoMod.brand)) { new PaneBranding().autoOverlay(GuiMainMenu.class); } RenderingRegistry.registerEntityRenderingHandler(EntityBlunderbussProjectile.class, new RenderBlunderbussProjectile()); RenderingRegistry.registerEntityRenderingHandler(EntityRifleProjectile.class, new RenderNull()); MinecraftForgeClient.registerItemRenderer(FarragoMod.RIFLE, new RifleItemRenderer()); MinecraftForgeClient.registerItemRenderer(FarragoMod.UNDEFINED, new UndefinedItemRenderer()); prevHotbar = new KeyBinding("key.farrago.utility_belt.prev_hotbar", Keyboard.KEY_MINUS, "key.categories.farrago.utility_belt"); nextHotbar = new KeyBinding("key.farrago.utility_belt.next_hotbar", Keyboard.KEY_EQUALS, "key.categories.farrago.utility_belt"); renameHotbar = new KeyBinding("key.farrago.utility_belt.rename_hotbar", Keyboard.KEY_BACK, "key.categories.farrago.utility_belt"); lockSlot = new KeyBinding("key.farrago.utility_belt.lock_slot", Keyboard.KEY_0, "key.categories.farrago.utility_belt"); ClientRegistry.registerKeyBinding(prevHotbar); ClientRegistry.registerKeyBinding(nextHotbar); ClientRegistry.registerKeyBinding(renameHotbar); ClientRegistry.registerKeyBinding(lockSlot); FarragoMod.lightPipeRenderType = RenderingRegistry.getNextAvailableRenderId(); FarragoMod.machineRenderType = RenderingRegistry.getNextAvailableRenderId(); RenderingRegistry.registerBlockHandler(new LightPipeBlockRenderer()); RenderingRegistry.registerBlockHandler(new MachineBlockRenderer()); IResourceManager manager = Minecraft.getMinecraft().getResourceManager(); if (manager instanceof IReloadableResourceManager) { ((IReloadableResourceManager)manager).registerReloadListener(new Encyclopedia()); } FMLCommonHandler.instance().bus().register(this); MinecraftForge.EVENT_BUS.register(this); UtilityBeltRenderer.showSwapSpace = FarragoMod.config.getBoolean("debug.showSwapSpace"); }
/** * Used to do the actual rendering. */ @Internal public static final void callAllRenderers(GuiIngame gui) { if (MCData.isClientSide()) { Iterator<ISpecialHUDRenderer> iterator = renderers.iterator(); while (iterator.hasNext()) { iterator.next().renderGUIElement(gui); } } }
@SuppressWarnings("MixinClassReference") private void hookIntoChat(GuiIngame guiIngame) throws Exception { if (!GuiNewChatTC.class.isAssignableFrom(guiIngame.getChatGUI().getClass())) { ((IGuiIngame) guiIngame).setPersistantChatGUI(chatGui); LOGGER.info("Successfully hooked into chat."); } }
public static void showLagometer(ScaledResolution p_showLagometer_0_) { if (gameSettings != null) { if (gameSettings.ofLagometer || gameSettings.field_181657_aC) { long i = System.nanoTime(); GlStateManager.clear(256); GlStateManager.matrixMode(5889); GlStateManager.pushMatrix(); GlStateManager.enableColorMaterial(); GlStateManager.loadIdentity(); GlStateManager.ortho(0.0D, (double)mc.displayWidth, (double)mc.displayHeight, 0.0D, 1000.0D, 3000.0D); GlStateManager.matrixMode(5888); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GlStateManager.disableTexture2D(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(1, DefaultVertexFormats.POSITION_COLOR); for (int j = 0; j < timesFrame.length; ++j) { int k = (j - numRecordedFrameTimes & timesFrame.length - 1) * 100 / timesFrame.length; k = k + 155; float f = (float)mc.displayHeight; long l = 0L; if (gcs[j]) { renderTime(j, timesFrame[j], k, k / 2, 0, f, worldrenderer); } else { renderTime(j, timesFrame[j], k, k, k, f, worldrenderer); f = f - (float)renderTime(j, timesServer[j], k / 2, k / 2, k / 2, f, worldrenderer); f = f - (float)renderTime(j, timesTerrain[j], 0, k, 0, f, worldrenderer); f = f - (float)renderTime(j, timesVisibility[j], k, k, 0, f, worldrenderer); f = f - (float)renderTime(j, timesChunkUpdate[j], k, 0, 0, f, worldrenderer); f = f - (float)renderTime(j, timesChunkUpload[j], k, 0, k, f, worldrenderer); f = f - (float)renderTime(j, timesScheduledExecutables[j], 0, 0, k, f, worldrenderer); float f2 = f - (float)renderTime(j, timesTick[j], 0, k, k, f, worldrenderer); } } renderTimeDivider(0, timesFrame.length, 33333333L, 196, 196, 196, (float)mc.displayHeight, worldrenderer); renderTimeDivider(0, timesFrame.length, 16666666L, 196, 196, 196, (float)mc.displayHeight, worldrenderer); tessellator.draw(); GlStateManager.enableTexture2D(); int j2 = mc.displayHeight - 80; int k2 = mc.displayHeight - 160; mc.fontRendererObj.drawString("30", 2, k2 + 1, -8947849); mc.fontRendererObj.drawString("30", 1, k2, -3881788); mc.fontRendererObj.drawString("60", 2, j2 + 1, -8947849); mc.fontRendererObj.drawString("60", 1, j2, -3881788); GlStateManager.matrixMode(5889); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); GlStateManager.popMatrix(); GlStateManager.enableTexture2D(); float f1 = 1.0F - (float)((double)(System.currentTimeMillis() - memTimeStartMs) / 1000.0D); f1 = Config.limit(f1, 0.0F, 1.0F); int l2 = (int)(170.0F + f1 * 85.0F); int i1 = (int)(100.0F + f1 * 55.0F); int j1 = (int)(10.0F + f1 * 10.0F); int k1 = l2 << 16 | i1 << 8 | j1; int l1 = 512 / p_showLagometer_0_.getScaleFactor() + 2; int i2 = mc.displayHeight / p_showLagometer_0_.getScaleFactor() - 8; GuiIngame guiingame = mc.ingameGUI; GuiIngame.drawRect(l1 - 1, i2 - 1, l1 + 50, i2 + 10, -1605349296); mc.fontRendererObj.drawString(" " + memMbSec + " MB/s", l1, i2, k1); renderTimeNano = System.nanoTime() - i; } } }
public static void showLagometer(ScaledResolution p_showLagometer_0_) { if (gameSettings != null && gameSettings.ofLagometer) { long i = System.nanoTime(); GlStateManager.clear(256); GlStateManager.matrixMode(5889); GlStateManager.pushMatrix(); GlStateManager.enableColorMaterial(); GlStateManager.loadIdentity(); GlStateManager.ortho(0.0D, (double)mc.displayWidth, (double)mc.displayHeight, 0.0D, 1000.0D, 3000.0D); GlStateManager.matrixMode(5888); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GlStateManager.disableTexture2D(); Tessellator tessellator = Tessellator.getInstance(); WorldRenderer worldrenderer = tessellator.getWorldRenderer(); worldrenderer.begin(1, DefaultVertexFormats.POSITION_COLOR); for (int j = 0; j < timesFrame.length; ++j) { int k = (j - numRecordedFrameTimes & timesFrame.length - 1) * 100 / timesFrame.length; k = k + 155; float f = (float)mc.displayHeight; long l = 0L; if (gcs[j]) { renderTime(j, timesFrame[j], k, k / 2, 0, f, worldrenderer); } else { renderTime(j, timesFrame[j], k, k, k, f, worldrenderer); f = f - (float)renderTime(j, timesServer[j], k / 2, k / 2, k / 2, f, worldrenderer); f = f - (float)renderTime(j, timesTerrain[j], 0, k, 0, f, worldrenderer); f = f - (float)renderTime(j, timesVisibility[j], k, k, 0, f, worldrenderer); f = f - (float)renderTime(j, timesChunkUpdate[j], k, 0, 0, f, worldrenderer); f = f - (float)renderTime(j, timesChunkUpload[j], k, 0, k, f, worldrenderer); f = f - (float)renderTime(j, timesScheduledExecutables[j], 0, 0, k, f, worldrenderer); float f2 = f - (float)renderTime(j, timesTick[j], 0, k, k, f, worldrenderer); } } tessellator.draw(); GlStateManager.matrixMode(5889); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); GlStateManager.popMatrix(); GlStateManager.enableTexture2D(); float f1 = 1.0F - (float)((double)(System.currentTimeMillis() - memTimeStartMs) / 1000.0D); f1 = Config.limit(f1, 0.0F, 1.0F); int l1 = (int)(170.0F + f1 * 85.0F); int i2 = (int)(100.0F + f1 * 55.0F); int j2 = (int)(10.0F + f1 * 10.0F); int i1 = l1 << 16 | i2 << 8 | j2; int j1 = 512 / p_showLagometer_0_.getScaleFactor() + 2; int k1 = mc.displayHeight / p_showLagometer_0_.getScaleFactor() - 8; GuiIngame guiingame = mc.ingameGUI; GuiIngame.drawRect(j1 - 1, k1 - 1, j1 + 50, k1 + 10, -1605349296); mc.fontRendererObj.drawString(" " + memMbSec + " MB/s", j1, k1, i1); renderTimeNano = System.nanoTime() - i; } }
public static void showLagometer(ScaledResolution p_showLagometer_0_) { if (gameSettings != null) { if (gameSettings.ofLagometer || gameSettings.showLagometer) { long i = System.nanoTime(); GlStateManager.clear(256); GlStateManager.matrixMode(5889); GlStateManager.pushMatrix(); GlStateManager.enableColorMaterial(); GlStateManager.loadIdentity(); GlStateManager.ortho(0.0D, (double)mc.displayWidth, (double)mc.displayHeight, 0.0D, 1000.0D, 3000.0D); GlStateManager.matrixMode(5888); GlStateManager.pushMatrix(); GlStateManager.loadIdentity(); GlStateManager.translate(0.0F, 0.0F, -2000.0F); GL11.glLineWidth(1.0F); GlStateManager.disableTexture2D(); Tessellator tessellator = Tessellator.getInstance(); VertexBuffer vertexbuffer = tessellator.getBuffer(); vertexbuffer.begin(1, DefaultVertexFormats.POSITION_COLOR); for (int j = 0; j < timesFrame.length; ++j) { int k = (j - numRecordedFrameTimes & timesFrame.length - 1) * 100 / timesFrame.length; k = k + 155; float f = (float)mc.displayHeight; long l = 0L; if (gcs[j]) { renderTime(j, timesFrame[j], k, k / 2, 0, f, vertexbuffer); } else { renderTime(j, timesFrame[j], k, k, k, f, vertexbuffer); f = f - (float)renderTime(j, timesServer[j], k / 2, k / 2, k / 2, f, vertexbuffer); f = f - (float)renderTime(j, timesTerrain[j], 0, k, 0, f, vertexbuffer); f = f - (float)renderTime(j, timesVisibility[j], k, k, 0, f, vertexbuffer); f = f - (float)renderTime(j, timesChunkUpdate[j], k, 0, 0, f, vertexbuffer); f = f - (float)renderTime(j, timesChunkUpload[j], k, 0, k, f, vertexbuffer); f = f - (float)renderTime(j, timesScheduledExecutables[j], 0, 0, k, f, vertexbuffer); float f2 = f - (float)renderTime(j, timesTick[j], 0, k, k, f, vertexbuffer); } } renderTimeDivider(0, timesFrame.length, 33333333L, 196, 196, 196, (float)mc.displayHeight, vertexbuffer); renderTimeDivider(0, timesFrame.length, 16666666L, 196, 196, 196, (float)mc.displayHeight, vertexbuffer); tessellator.draw(); GlStateManager.enableTexture2D(); int j2 = mc.displayHeight - 80; int k2 = mc.displayHeight - 160; mc.fontRendererObj.drawString("30", 2, k2 + 1, -8947849); mc.fontRendererObj.drawString("30", 1, k2, -3881788); mc.fontRendererObj.drawString("60", 2, j2 + 1, -8947849); mc.fontRendererObj.drawString("60", 1, j2, -3881788); GlStateManager.matrixMode(5889); GlStateManager.popMatrix(); GlStateManager.matrixMode(5888); GlStateManager.popMatrix(); GlStateManager.enableTexture2D(); float f1 = 1.0F - (float)((double)(System.currentTimeMillis() - memTimeStartMs) / 1000.0D); f1 = Config.limit(f1, 0.0F, 1.0F); int l2 = (int)(170.0F + f1 * 85.0F); int i1 = (int)(100.0F + f1 * 55.0F); int j1 = (int)(10.0F + f1 * 10.0F); int k1 = l2 << 16 | i1 << 8 | j1; int l1 = 512 / p_showLagometer_0_.getScaleFactor() + 2; int i2 = mc.displayHeight / p_showLagometer_0_.getScaleFactor() - 8; GuiIngame guiingame = mc.ingameGUI; GuiIngame.drawRect(l1 - 1, i2 - 1, l1 + 50, i2 + 10, -1605349296); mc.fontRendererObj.drawString(" " + memMbSec + " MB/s", l1, i2, k1); renderTimeNano = System.nanoTime() - i; } } }
public static void renderCD() { GuiIngame gui = Minecraft.getMinecraft().ingameGUI; RenderHelper.enableAlpha(); int i = -1; ScaledResolution resolution = new ScaledResolution(Minecraft.getMinecraft()); int width = resolution.getScaledWidth() * 2; int height = resolution.getScaledHeight() * 2; for (ICoolDown cd : cool_downs) { float cd_per = Math.min((float) cd.getResidualCD() / cd.getMaxCD(), 1); if (cd_per <= 0) continue; ++i; int x = getCDXStart(i), y = getCDYStart(i), snake = Tool.isNullOr(snakes.get(cd), 0), sx = 0, sy = 0; if (snake > 0) { snakes.put(cd, cd.getResidualCD() == 1 ? 0 : --snake); sx = Tool.getRandom(-SNAKE, SNAKE); sy = Tool.getRandom(-SNAKE, SNAKE); } x = width - x; y = height - y; System.out.println(x + " - " + y); RenderHelper.pushMatrix(); RenderHelper.scale(0.5F, 0.5F, 1F); RenderHelper.translate(sx, sy, 0); RenderHelper.scale(2F, 2F, 1F); glEnable(GL_COLOR_ARRAY); bind(GuiContainer.INVENTORY_BACKGROUND); gui.drawTexturedModalRect(x / 2, y / 2, 141, 166, MC_BG_TEXTURE_SIZE, MC_BG_TEXTURE_SIZE); RenderHelper.scale(0.5F, 0.5F, 1F); bind(CD_BG); int id = cd.getRenderID(); if (id > -1) gui.drawTexturedModalRect(x, y, CD_SIZE * (id % ON_ROW), CD_SIZE * (id / ON_ROW), CD_SIZE, CD_SIZE); cd.renderCD(x, y, CD_SIZE, CD_SIZE); glDisable(GL_COLOR_ARRAY); int cd_per_len = (int) ((CD_SIZE - INTERVAL * 2) * cd_per); Gui.drawRect(x + INTERVAL, y + (CD_SIZE - INTERVAL * 2 - cd_per_len) + INTERVAL, x + CD_SIZE - INTERVAL, y + CD_SIZE - INTERVAL, 0x99000000); RenderHelper.scale(2F, 2F, 1F); RenderHelper.popMatrix(); } RenderHelper.disableAlpha(); }
@SideOnly(Side.CLIENT) public void renderGUI(BufferBuilder renderer, Tessellator tessellator, EntityPlayer player, int width, int height, GuiIngame gui) { }
/** * Where the rendering is done. * @param gui The HUD GUI. */ public void renderGUIElement(GuiIngame gui);