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

I have a Event Handler and I would like to register it. Does it matter in which FMLInitializationEvent I put in?

 

Main Mod class

@Mod(name = Reference.MOD_NAME, modid = Reference.MOD_ID, version = Reference.VERSION, acceptedMinecraftVersions = "1.12.2")
public class GemEnchantmentMod {

	static {
		FluidRegistry.enableUniversalBucket();
	}

	@SidedProxy(clientSide = Reference.CLIENT_PROXY, serverSide = Reference.SERVER_PROXY)
	public static CommonProxy proxy;

	public static final SimpleNetworkWrapper INSTANCE = NetworkRegistry.INSTANCE.newSimpleChannel("edm");

	@Instance
	public static GemEnchantmentMod instance;

	public static GemEnchantmentModCreativeTab mainTab = new GemEnchantmentModCreativeTab("mainGemEnchantmentMod",
			new ItemStack(ModItems.fireGem, 1));

	@EventHandler
	public static void PreInit(FMLPreInitializationEvent event) {
	}

	@EventHandler
	public static void Init(FMLInitializationEvent event) {
		proxy.init();
	}

	@EventHandler
	public static void PostInit(FMLPostInitializationEvent event) {

	}

}

 

EventHandler class

public class EventHandler {
	
	@SideOnly(Side.CLIENT)
	@SubscribeEvent(priority=EventPriority.NORMAL, receiveCanceled=true)
	public void onEvent(RenderGameOverlayEvent.Pre event)
	{
		if (event.getType() == ElementType.ALL)
		{
			
			EntityPlayer thePlayer = Minecraft.getMinecraft().player;
			
			if (thePlayer.isInsideOfMaterial(ModMaterials.ENCHANTED))
			{	
				drawFluidOverlay(ModFluids.enchantedFluid.getColor(), 0.2F);
			}			
		}
	}
  		
    /**
     * Draws a rectangle with the specified color
     */
	@SideOnly(Side.CLIENT)
     public static void drawFluidOverlay(int parColor, float parAlpha)
    {	
		int left = 0;
		int top = 0;
		int right = Minecraft.getMinecraft().displayWidth;
		int bottom = Minecraft.getMinecraft().displayHeight;
 		Color color = Color.GREEN;
        Tessellator tessellator = Tessellator.getInstance();
        BufferBuilder bufferbuilder = tessellator.getBuffer();
        GlStateManager.enableBlend();
        GlStateManager.disableTexture2D();
        GlStateManager.tryBlendFuncSeparate(GlStateManager.SourceFactor.SRC_ALPHA, GlStateManager.DestFactor.ONE_MINUS_SRC_ALPHA, GlStateManager.SourceFactor.ONE, GlStateManager.DestFactor.ZERO);
        GlStateManager.color(color.getRed(), color.getGreen(), color.getBlue(), parAlpha);
        bufferbuilder.begin(7, DefaultVertexFormats.POSITION);
        bufferbuilder.pos(left, bottom, 0.0D).endVertex();
        bufferbuilder.pos(right, bottom, 0.0D).endVertex();
        bufferbuilder.pos(right, top, 0.0D).endVertex();
        bufferbuilder.pos(left, top, 0.0D).endVertex();
        tessellator.draw();
        GlStateManager.enableTexture2D();
        GlStateManager.disableBlend();
    }
	
}

 

Edited by DeathSpawn

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.