Jump to content

Capabilities is not registrated on the server.


Durex77

Recommended Posts

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 by Durex77
Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.