Java Code Examples for net.minecraftforge.client.event.RenderGameOverlayEvent#Post

The following examples show how to use net.minecraftforge.client.event.RenderGameOverlayEvent#Post . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TacoCmd.java    From ForgeWurst with GNU General Public License v3.0 6 votes vote down vote up
@SubscribeEvent
public void onRenderGUI(RenderGameOverlayEvent.Post event)
{
	if(event.getType() != ElementType.ALL || mc.gameSettings.showDebugInfo)
		return;
	
	if(wurst.getHax().rainbowUiHack.isEnabled())
	{
		float[] acColor = wurst.getGui().getAcColor();
		GL11.glColor4f(acColor[0], acColor[1], acColor[2], 1);
	}else
		GL11.glColor4f(1, 1, 1, 1);
	
	int tacoId = WMinecraft.getPlayer().ticksExisted % 32 / 8;
	ResourceLocation tacoLocation = tacos[tacoId];
	mc.getTextureManager().bindTexture(tacoLocation);
	
	ScaledResolution sr = new ScaledResolution(mc);
	int x = sr.getScaledWidth() / 2 + 44;
	int y = sr.getScaledHeight() - 51;
	int w = 64;
	int h = 32;
	Gui.drawModalRectWithCustomSizedTexture(x, y, 0, 0, w, h, w, h);
}
 
Example 2
Source File: ControlEventsClient.java    From Valkyrien-Skies with Apache License 2.0 6 votes vote down vote up
@SubscribeEvent
public void render(RenderGameOverlayEvent.Post event) {
    Minecraft minecraft = Minecraft.getMinecraft();
    EntityPlayer player = Minecraft.getMinecraft().player;
    FontRenderer fontRenderer = minecraft.fontRenderer;
    if (fontRenderer != null && player != null && event.getType()
        == net.minecraftforge.client.event.RenderGameOverlayEvent.ElementType.TEXT) {
        IShipPilot playerPilot = (IShipPilot) player;
        if (playerPilot.isPiloting()) {
            BlockPos tilePilotedPos = playerPilot.getPosBeingControlled();
            TileEntity pilotedTile = player.getEntityWorld().getTileEntity(tilePilotedPos);
            if (pilotedTile instanceof TileEntityPilotableImpl) {
                TileEntityPilotableImpl pilotedControlEntity = (TileEntityPilotableImpl) pilotedTile;
                ScaledResolution scaledresolution = new ScaledResolution(
                    Minecraft.getMinecraft());
                pilotedControlEntity.renderPilotText(fontRenderer, scaledresolution);
            }
        }
    }
}
 
Example 3
Source File: RenderListener.java    From SkyblockAddons with MIT License 5 votes vote down vote up
/**
 * Render overlays and warnings for clients without labymod.
 */
@SubscribeEvent()
public void onRenderRegular(RenderGameOverlayEvent.Post e) {
    if ((!main.isUsingLabymod() || Minecraft.getMinecraft().ingameGUI instanceof GuiIngameForge)) {
        if (e.type == RenderGameOverlayEvent.ElementType.EXPERIENCE || e.type == RenderGameOverlayEvent.ElementType.JUMPBAR) {
            if (main.getUtils().isOnSkyblock()) {
                renderOverlays();
                renderWarnings(e.resolution);
            } else {
                renderTimersOnly();
            }
            drawUpdateMessage();
        }
    }
}
 
Example 4
Source File: ShowNoticeFirst.java    From I18nUpdateMod with MIT License 5 votes vote down vote up
@SubscribeEvent
public static void onPlayerFirstJoin(RenderGameOverlayEvent.Post event) {
    if (shouldShowNotice && event.getType() != RenderGameOverlayEvent.ElementType.HELMET && I18nConfig.notice.showNoticeConfig) {
        shouldShowNotice = false;
        new NoticeShower();
    }
}
 
Example 5
Source File: ChatMsgHandler.java    From BakaDanmaku with MIT License 5 votes vote down vote up
/**
 * 游戏界面显示人气值
 * TODO: 取消人气值与单独 Handler 的关联
 *
 * @param e 渲染游戏界面事件
 */
@SubscribeEvent
public static void showPopularityCount(RenderGameOverlayEvent.Post e) {
    GuiIngame gui = Minecraft.getMinecraft().ingameGUI; // 获取 Minecraft 实例中的 GUI
    FontRenderer renderer = Minecraft.getMinecraft().fontRenderer; // 获取 Minecraft 原版字体渲染器

    // 当渲染快捷栏时候进行显示,意味着 F1 会隐藏
    if (e.getType() == RenderGameOverlayEvent.ElementType.HOTBAR && gui != null && BakaDanmakuConfig.general.showPopularity) {
        double x = (Minecraft.getMinecraft().displayWidth * BakaDanmakuConfig.general.posX) / 100; // 获取的配置宽度百分比
        double y = (Minecraft.getMinecraft().displayHeight * BakaDanmakuConfig.general.posY) / 100; // 获取的配置高度百分比

        gui.drawString(renderer, String.format(BakaDanmakuConfig.general.popularityStyle, String.valueOf(tmpPopularityCount)),
                (int) x, (int) y, BakaDanmakuConfig.general.color);
    }
}
 
Example 6
Source File: ItemManaLens.java    From Cyberware with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawScreenPost(RenderGameOverlayEvent.Post event)
{
	EntityPlayer p = Minecraft.getMinecraft().thePlayer;
	
	if (hasLensNotMonocle(p))
	{
		//ItemMonocle.renderHUD(event.getResolution(), p);
	}
}
 
Example 7
Source File: VanillaWares.java    From Cyberware with MIT License 5 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawScreenPost(RenderGameOverlayEvent.Post event)
{
	if (event.getType() == ElementType.CROSSHAIRS)
	{
		EntityPlayer p = Minecraft.getMinecraft().thePlayer;
		if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(Items.SPIDER_EYE)))
		{
			GlStateManager.translate(0, -event.getResolution().getScaledHeight() / 5, 0);
		}
	}
}
 
Example 8
Source File: RenderEventHandler.java    From enderutilities with GNU Lesser General Public License v3.0 5 votes vote down vote up
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Post event)
{
    if (event.getType() != ElementType.ALL)
    {
        return;
    }

    if ((this.mc.currentScreen instanceof GuiChat) == false && this.mc.player != null)
    {
        this.buildersWandRenderer.renderHud(this.mc.player);
        this.rulerRenderer.renderHud();
        this.renderPlacementPropertiesHud(this.mc.player);
    }
}
 
Example 9
Source File: TerminalManagerClient.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
@SubscribeEvent
public void onRenderGameOverlay(RenderGameOverlayEvent.Post evt) {
	if (evt.type == ElementType.HELMET) {
		if (terminalGuid.isPresent()) {
			final long guid = terminalGuid.get();
			tryDrawSurface(guid, SurfaceType.PRIVATE, evt.partialTicks, evt.resolution);
			tryDrawSurface(guid, SurfaceType.GLOBAL, evt.partialTicks, evt.resolution);
		}
	}
}
 
Example 10
Source File: PlayerOverlay.java    From MediaMod with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Fired when a game overlay is being rendered
 *
 * @param event - RenderGameOverlayEvent
 * @see RenderGameOverlayEvent
 */
@SubscribeEvent
public void onRender(RenderGameOverlayEvent.Post event) {
    // Get a Minecraft Instance
    Minecraft mc = FMLClientHandler.instance().getClient();

    if (event.type.equals(RenderGameOverlayEvent.ElementType.EXPERIENCE) && Settings.SHOW_PLAYER && Settings.ENABLED) {
        if (this.first) {
            // Make sure that this is never ran again
            this.first = false;

            // Setup a ScheduledExecutorService to run every 3 seconds
            ScheduledExecutorService exec = Executors.newSingleThreadScheduledExecutor();
            exec.scheduleAtFixedRate(() -> {
                try {
                    // Check if we are ready
                    if (ServiceHandler.INSTANCE.getCurrentMediaHandler() != null) {
                        if (ServiceHandler.INSTANCE.getCurrentMediaHandler().handlerReady()) {
                            this.currentlyPlayingObject = ServiceHandler.INSTANCE.getCurrentMediaHandler().getCurrentTrack();
                            if(this.previousPlayingObject == null || !this.previousPlayingObject.item.name.equals(this.currentlyPlayingObject.item.name)) {
                                this.previousPlayingObject = this.currentlyPlayingObject;
                                MinecraftForge.EVENT_BUS.post(new SongChangeEvent(this.currentlyPlayingObject));
                                if(Settings.ANNOUNCE_TRACKS) PlayerMessager.sendMessage(ChatColor.GRAY + "Current track: " + this.currentlyPlayingObject.item.name + " by "  + this.currentlyPlayingObject.item.album.artists[0].name, true);
                            }
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }, 0, 3, TimeUnit.SECONDS);
        }

        // Make sure that a MediaHandler exists and is ready
        IMediaHandler currentHandler = ServiceHandler.INSTANCE.getCurrentMediaHandler();
        if (currentHandler != null && currentHandler.handlerReady() && currentlyPlayingObject != null) {
            // Make sure there's no GUI screen being displayed
            if (mc.currentScreen == null && !mc.gameSettings.showDebugInfo) {
                this.drawPlayer(Settings.PLAYER_X, Settings.PLAYER_Y, Settings.MODERN_PLAYER_STYLE, false, Settings.PLAYER_ZOOM);
            }
        }
    }
}
 
Example 11
Source File: IngameHUD.java    From ForgeWurst with GNU General Public License v3.0 4 votes vote down vote up
@SubscribeEvent
public void onRenderGUI(RenderGameOverlayEvent.Post event)
{
	if(event.getType() != ElementType.ALL || mc.gameSettings.showDebugInfo)
		return;
	
	boolean blend = GL11.glGetBoolean(GL11.GL_BLEND);
	
	// color
	clickGui.updateColors();
	int textColor;
	if(hackList.rainbowUiHack.isEnabled())
	{
		float[] acColor = clickGui.getAcColor();
		textColor = (int)(acColor[0] * 256) << 16
			| (int)(acColor[1] * 256) << 8 | (int)(acColor[2] * 256);
	}else
		textColor = 0xffffff;
	
	// title
	GL11.glPushMatrix();
	GL11.glScaled(1.33333333, 1.33333333, 1);
	WMinecraft.getFontRenderer().drawStringWithShadow(
		"ForgeWurst v" + ForgeWurst.VERSION, 3, 3, textColor);
	GL11.glPopMatrix();
	
	// hack list
	int y = 19;
	ArrayList<Hack> hacks = new ArrayList<>();
	hacks.addAll(hackList.getValues());
	hacks.sort(Comparator.comparing(Hack::getName));
	
	for(Hack hack : hacks)
	{
		if(!hack.isEnabled())
			continue;
		
		WMinecraft.getFontRenderer()
			.drawStringWithShadow(hack.getRenderName(), 2, y, textColor);
		y += 9;
	}
	
	// pinned windows
	if(!(mc.currentScreen instanceof ClickGuiScreen))
		clickGui.renderPinnedWindows(event.getPartialTicks());
	
	if(blend)
		GL11.glEnable(GL11.GL_BLEND);
	else
		GL11.glDisable(GL11.GL_BLEND);
}
 
Example 12
Source File: ItemLungsUpgrade.java    From Cyberware with MIT License 4 votes vote down vote up
@SideOnly(Side.CLIENT)
@SubscribeEvent
public void onDrawScreenPost(RenderGameOverlayEvent.Post event)
{
	if (event.getType() == ElementType.AIR)
	{
		EntityPlayer p = Minecraft.getMinecraft().thePlayer;
		if (CyberwareAPI.isCyberwareInstalled(p, new ItemStack(this, 1, 0)) && !p.isCreative())
		{
			GL11.glPushMatrix();
			ItemStack stack = CyberwareAPI.getCyberware(p, new ItemStack(this, 1, 0));
			int air = getAir(stack);
			
			Minecraft.getMinecraft().getTextureManager().bindTexture(Gui.ICONS);
	
			ScaledResolution res = event.getResolution();
			GlStateManager.enableBlend();
			int left = res.getScaledWidth() / 2 + 91;
			int top = res.getScaledHeight() - 49 - 8;//- right_height;
			
			float r = 1F;
			float b = 1F;
			float g = 1F;

		
			if (p.isInsideOfMaterial(Material.WATER))
			{
				while (air > 0)
				{
					r += 1F;
					b -= .25F;
					g += .25F;
					GL11.glColor3f(r, g, b);
					int drawAir = Math.min(300, air);
					int full = MathHelper.ceiling_double_int((double)(drawAir - 2) * 10.0D / 300.0D);
					int partial = MathHelper.ceiling_double_int((double)drawAir * 10.0D / 300.0D) - full;
			
					for (int i = 0; i < full + partial; ++i)
					{
						ClientUtils.drawTexturedModalRect(left - i * 8 - 9, top, (i < full ? 16 : 25), 18, 9, 9);
					}
					
					
					air -= 300;
					top -= 8;
				}
			}
		
			GL11.glColor3f(1.0F, 1.0F, 1.0F);
			//GlStateManager.disableBlend();
			GL11.glPopMatrix();
		}
	}
}
 
Example 13
Source File: MwForge.java    From mapwriter with MIT License 4 votes vote down vote up
@SubscribeEvent
public void renderMap(RenderGameOverlayEvent.Post event){
    if(event.type == RenderGameOverlayEvent.ElementType.ALL){
        Mw.instance.onTick();
    }
}