-
Notifications
You must be signed in to change notification settings - Fork 0
Registering your Screen
We now need to register our BuilderScreen, and then we are done.
- Make a new class in the init package.
If you are on MultiLoader, you will need to do this in the loader-specific modules.
-
Name the class
ModScreenFactories, or another name you like. -
Make sure to annotate the class with
@OnlyIn(Dist.CLIENT)(NeoForge) or@Environment(EnvType.CLIENT)(Fabric). This is very important, or trying to launch a server with the mod will cause it to crash. -
Once again, make a new void
register()method. -
Inside, call
BuilderScreenRegistry.register(String type, Function<BuilderContext, BuilderScreen> factory). This connects our BuilderScreen to the Requirement.
It should look like this (NeoForge example):
@OnlyIn(Dist.CLIENT)
public class ModScreenFactories {
public static void register() {
BuilderScreenRegistry.register("blocks_broken", BuilderBlocksBrokenScreen::new);
}
}- In a different class, you need to listen to the
FMLClientSetupEventevent on NeoForge, or on Fabric the Client initialization entrypoint might work. There, call theModScreenFactories.register();method. If you are using the event, make sure that the value is set to the Client Dist, and you are using the Mod Bus.
NeoForge example:
@EventBusSubscriber(modid = Constants.MOD_ID, value = Dist.CLIENT, bus = EventBusSubscriber.Bus.MOD)
public class ClientSetupEvents {
@SubscribeEvent
public static void onClientSetup(FMLClientSetupEvent event) {
ModScreenFactories.register();
}
}Now you're all done! You created a mod that functions as an Addon to Access Denied. Have fun!