Jump to content

Recommended Posts

Posted (edited)

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...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

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