Skip to content

Forge Client Sided Events

John Doe edited this page Mar 13, 2022 · 1 revision

The following classes are from the package net.minecraftforge.client.event in the library forgeSrc-1.8.9-11.15.1.2318-1.8.9.jar. They all should have the annotations @SideOnly(Side.CLIENT) and need to have the annotation @SubscribeEvent when used in a method body of a class that has been registered in the MinecraftForge.EVENT_BUS.

ClientChatReceivedEvent

  • Trigger: When the server sent a chat message. Both the player chat (type 0) and the messages directly over the hotbar (type 2) count to those.
  • Attributes: event.type as explained above and event.message as the formated text displayed.

GuiScreenEvent

  • Trigger: Whenever a GUI shows up. One usecase would be the GuiChest element in the event.gui of the GuiScreenEvent.InitGuiEvent.Post event.
  • Attributes: event.gui contains the gui element that triggered the event. This could, from the example above, be a GuiChest, in which case the following command would return the inventory of the chest IInventory chestInventory = ((ContainerChest) ((GuiChest) event.gui).inventorySlots).getLowerChestInventory()
  • Notes: It is recommended to wait a few milliseconds (somewhere around 50ms should be good, maybe even more) after this event, before the chest inventory is analysed, to wait for it to fully load its contents.

sound.PlaySoundEvent

  • Trigger: Whenever there is a sound played in the world.
  • Attributes: event.name is a String that represents the sound. A list of those can be found here. event.sound contains things like the pitch, volume and sound location.

RenderWorldLastEvent

  • Trigger: Every frame.
  • Attributes: event.partialTicks is important for the render functions the RenderUtil from Moulberry provide.

MouseEvent

  • Trigger: Left mouse click
  • Attributes: event.button - 0 left, 1 right, 2 middle click
  • Note: There are a few problems with this where it doesnt work with right click...

More client events

DrawBlockHighlightEvent EntityViewRenderEvent FOVUpdateEvent GuiOpenEvent ModelBakeEvent RenderBlockOverlayEvent RenderGameOverlayEvent RenderHandEvent RenderItemInFrameEvent RenderLivingEvent RenderPlayerEvent RenderWorldEvent TextureStitchEvent

Clone this wiki locally