Cardinal Components API

Cardinal Components API

21M Downloads

Wiki codes out-of-date?

yuesha-yc opened this issue ยท 1 comments

commented

MC version: 1.16.1
Cardinal Components Version: 2.4.2

Hi I tried the wiki example to register a component. I have a question regarding this.

public class Handler_Components implements EntityComponentInitializer {

    public static final ComponentType<IComponentFloat> FLOAT_COMPONENT_TYPE =
            ComponentRegistry.INSTANCE.registerIfAbsent(new Identifier("eltcore:float"), IComponentFloat.class);

    @Override
    public void registerEntityComponentFactories(EntityComponentFactoryRegistry registry) {
        registry.register(FLOAT_COMPONENT_TYPE, IComponentFloat::new);
    }
}

This method does not work because it requires three components.
registry.register(FLOAT_COMPONENT_TYPE, IComponentFloat::new);
And my entry point is added.

"entrypoints": {
    "cardinal-components-entity": [
      "net.moeg.eltcore.handlers.Handler_Components"
    ]
  },

I saw in the source saying that many of these above methods are experimental or scheduled to be removed. Can you recommend a stable version to use Cardinal-Components-API? I like the mod's utility very much.

commented

This method does not work because it requires three components.

Entity components require you to tell the API what type of entity the component should be attached to, by passing the entity class. see the javadoc comment on that interface.

I saw in the source saying that many of these above methods are experimental or scheduled to be removed.

The V3 api is somewhat in flux still, it will be promoted to stable in 1.17.
If you don't want that, use the old way of registering component factories via the respective events instead.