Skip to content

Latest commit

 

History

History
22 lines (18 loc) · 630 Bytes

pseudo-mixin.md

File metadata and controls

22 lines (18 loc) · 630 Bytes

Mixing into classes that may not exist at runtime

<- Return

It may be necessary to inject code into a class of another mod. There may not be any guarantee that the mod will be present at runtime (in a production environment). Leaving the mixin as-is will cause the game to crash if the mod is not present. To work around this, use the @Pseudo annotation.

Example mixin-

@Pseudo
@Mixin(ServerLifecycleEvents.class)
public class FabricApiMixin {
  @Shadow
  @Final
  @Mutable
  public static Event<ServerLifecycleEvents.ServerStarting> SERVER_STARTING;

  static {
    SERVER_STARTING = null;
  }
}