Posted May 16, 20223 yr I am trying to use capabilities in my new project. And looks like FMLCommonSetupEvent event is not triggered during world loading. I debuged the code and setup(final FMLCommonSetupEvent event) was called once. After I launched the cliend. But it wasn't called when I created a server (single player server). So as a result my capability wasn't registrated. My Mod class: @Mod(MOD_ID) public class Lineage { public static final String MOD_ID = "lineage"; public static final String MOD_NAME = "Lineage"; // Directly reference a log4j logger. public static final Logger LOGGER = LogManager.getLogger(); public static CommonProxy proxy; public Lineage() { proxy = DistExecutor.safeRunForDist(() -> ClientProxy::new, () -> CommonProxy::new); // Register the setup method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::setup); // Register the enqueueIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::enqueueIMC); // Register the processIMC method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::processIMC); // Register the doClientStuff method for modloading FMLJavaModLoadingContext.get().getModEventBus().addListener(this::doClientStuff); // Register ourselves for server and other game events we are interested in MinecraftForge.EVENT_BUS.register(this); MinecraftForge.EVENT_BUS.register(new CapabilityHandler()); } private void setup(final FMLCommonSetupEvent event) { CapabilityManager.INSTANCE.register(IPlayerAdditionalProperties.class, new PlayerAdditionalPropertiesStorage(), PlayerAdditionalProperties::new); NetworkHandler.register(); proxy.init(); } private void doClientStuff(final FMLClientSetupEvent event) { MinecraftForge.EVENT_BUS.register(new KeyHandler()); } private void enqueueIMC(final InterModEnqueueEvent event) { } private void processIMC(final InterModProcessEvent event) { } // You can use SubscribeEvent and let the Event Bus discover methods to call @SubscribeEvent public void onServerStarting(FMLServerStartingEvent event) { // do something when the server starts } } Forge version 'net.minecraftforge:forge:1.16.5-36.2.35' Github: https://github.com/salimAbdulIt/lineage Edited May 16, 20223 yr by Durex77
May 16, 20223 yr Author I rebuilt everything. Cleaned caches. And not everything is fine. Edited May 16, 20223 yr by Durex77
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.