Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

When drawing a rectangle during the RenderGameOverlayEvent the hot bar gets tinted very strangely. The effect seems to vary between day and night too.

Here's the code for the overlay.

 

@Mod.EventBusSubscriber(modid = WeaponsCore.ID, value = {Side.CLIENT})
public class OverlayReload extends Gui
{
	@SubscribeEvent
	public static void render(RenderGameOverlayEvent.Post event)
	{
		if(event.getType() != RenderGameOverlayEvent.ElementType.HOTBAR)
		{
			//if (Minecraft.getMinecraft().playerController.shouldDrawHUD())
			//{
				renderReload(event.getResolution());
			//}
		}
	}

	public static void renderReload(ScaledResolution resolution) // TODO
	{
		Minecraft mc = Minecraft.getMinecraft();
		if (mc.getRenderViewEntity() instanceof EntityPlayer)
		{
			EntityPlayer player = (EntityPlayer) mc.getRenderViewEntity();
			ItemStack stack = player.getHeldItemMainhand(); //  TODO
			if(player.isHandActive())
			{
				if(stack.getItem() != null && stack.getItem() instanceof WeaponRanged)
				{
					float reload = Math.min((float) player.getItemInUseMaxCount() / (float) ((WeaponRanged) stack.getItem()).getRangedComponent().getProperties().getReload(), 1F);
					int color = 0;
					if(ReloadHelper.isEmpty(stack))
					{
						if(reload < 1F)
						{
							color = 0x60EAA800;
						}
						else
						{
							color = 0x60348E00;
						}
					}
					else if(ReloadHelper.isReloaded(stack))
					{
						color = 0x60C60000;
						reload = 1F;
					}
					int slot = player.inventory.getSlotFor(stack);
					GlStateManager.color(1F, 1F, 1F, 1F);
					GlStateManager.pushAttrib();
					int x0 = resolution.getScaledWidth() / 2 - 88 + slot * 20;
					int y0 = resolution.getScaledHeight() - 3;
					drawRect(x0, y0, x0 + 16, y0 - (int) (reload * 16), color);
					GlStateManager.popAttrib();
				}
			}
		}
	}
}

 

Untitled.png

Edited by Melonslise

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.