Changes

205 bytes removed ,  18:03, 8 December 2021
m
Event bus grammar
Line 26: Line 26:  
To mark an event as having a result, the event class should be annotated with <code>@Event.HasResult</code>. This will automatically make <code>Event#hasResult</code> return <code>true</code>. Modders may check if an event has a result through the presence of the annotation or by calling the given method.
 
To mark an event as having a result, the event class should be annotated with <code>@Event.HasResult</code>. This will automatically make <code>Event#hasResult</code> return <code>true</code>. Modders may check if an event has a result through the presence of the annotation or by calling the given method.
   −
== Event Bus ==
+
==Event Bus==
 
An '''event bus''' is an object which holds a list of event listeners, and the logic for firing the events. Events may be posted on these event buses, which then invokes the handlers. The main class for event buses is <code>IEventBus</code>, and a bus is created using <code>BusBuilder</code>.
 
An '''event bus''' is an object which holds a list of event listeners, and the logic for firing the events. Events may be posted on these event buses, which then invokes the handlers. The main class for event buses is <code>IEventBus</code>, and a bus is created using <code>BusBuilder</code>.
   −
A more detailed explanation at https://dzone.com/articles/design-patterns-event-bus.
+
You can find a more detailed explanation on the Event Bus pattern[https://dzone.com/articles/design-patterns-event-bus here.]
 +
===Existing Buses===
 +
Forge exposes three main families of event buses: the main Forge event bus, the mod-specific event buses, and the network channel event buses.
 +
====Main Forge Event Bus====
 +
The '''main Forge event bus''' is located at <code>MinecraftForge#EVENT_BUS</code>, and is where most events relating to ingame actions or events are fired on, such as events for ticking, block interactions, and entity interactions.  
   −
=== Existing Buses ===
  −
Forge exposes three main families of event buses: the main Forge event bus, the mod-specific event buses, and the network channel event buses.
     −
==== Main Forge Event Bus ====
+
List of events fired on the main Forge event bus{{:Events/Forge bus}}
The '''main Forge event bus''' is located at <code>MinecraftForge#EVENT_BUS</code>, and is where most events relating to ingame actions or events are fired on, such as events for ticking, block interactions, and entity interactions.
     −
<div class="mw-collapsible mw-collapsed" style="border: 2px solid; border-radius: 2px; padding: 5px; margin: 1em; overflow:auto;">
  −
<div style="font-weight:bold; line-height:1.6;">List of events fired on the main Forge event bus</div>
  −
<div class="mw-collapsible-content">
  −
{{:Events/Forge bus}}
  −
</div></div>
     −
==== Mod-Specific Event Buses ====
+
====Mod-Specific Event Buses====
 
The '''mod-specific event buses''' are the family of event buses where mod-related initialization and registration events are fired, such as the events for [[Registration|registering objects]] or setup on different physical sides. Only events which implement <code>IModBusEvent</code> may be fired or listened for on these event buses.
 
The '''mod-specific event buses''' are the family of event buses where mod-related initialization and registration events are fired, such as the events for [[Registration|registering objects]] or setup on different physical sides. Only events which implement <code>IModBusEvent</code> may be fired or listened for on these event buses.
   Line 49: Line 45:     
{{Tip|title=Tip|The mod-specific event buses are provided by the <code>javafml</code> language provider which is builtin to Forge Mod Loader. Custom language providers may provide other ways for mods to receive the different mod-related initialization and registration events; see the documentation of your custom language provider for details.}}
 
{{Tip|title=Tip|The mod-specific event buses are provided by the <code>javafml</code> language provider which is builtin to Forge Mod Loader. Custom language providers may provide other ways for mods to receive the different mod-related initialization and registration events; see the documentation of your custom language provider for details.}}
 
+
====Network Channel Event Buses====
==== Network Channel Event Buses ====
   
The '''network channel event buses''' are the family of event buses where different network-related events are fired. Each registered [[Networking|networking channel]] has their own instance of an event-bus in <code>NetworkInstance</code>, where only events pertinent to that channel are fired on.
 
The '''network channel event buses''' are the family of event buses where different network-related events are fired. Each registered [[Networking|networking channel]] has their own instance of an event-bus in <code>NetworkInstance</code>, where only events pertinent to that channel are fired on.