Jump to content

[SOLVED][1.14.4] AttachCapabilitiesEvent<TileEntity> event doesn't seem to fire


dylandmrl

Recommended Posts

Hello guys,

 

I usually try to fix things by myself using sources but here I am stuck. I don't know why since I saw many examples here and in github but nothing seems to work...

I try to implement an easy capability that just store one data to begin with, then I try to attached this one on a tile entity but when I use getCapability, nothing is attached. Even worst, the "onAttachCapability" function in the follow code doesn't seems to be called :

@Mod(MyMod.MOD_ID)
@Mod.EventBusSubscriber(bus=Mod.EventBusSubscriber.Bus.MOD, modid = MyMod.MOD_ID)
public class MyMod
{
    public static final String MOD_ID = "mymod";
    public static final String MOD_NAME = "My Mod";
    public static final String MOD_VERSION = "0.0.1 ";

    public static final ResourceLocation PACKET_CAPABILITY_LOCATION = new ResourceLocation(MyMod.MOD_ID, "packet_capability");

      public MyMod() {
        Debugger.debug("Start My Mod");
        MinecraftForge.EVENT_BUS.register(this);
    }
  
    ...Stuff

    @SubscribeEvent
    public static void onCapabilityRegistry(FMLCommonSetupEvent event) {
        Debugger.debug("Register Capabilities");
        CapabilityManager.INSTANCE.register(IPacket.class, new PacketStorage(), Packet::new);
    }

    @SubscribeEvent
    public static void onAttachCapability(AttachCapabilitiesEvent<TileEntity> event) {
        Debugger.debug("Attach Capabilities");
        TileEntity te = event.getObject();
        if (te instanceof IDataReceiver) {
            event.addCapability(PACKET_CAPABILITY_LOCATION, new PacketProvider());
        }
    }
}

I really have no idea, everything else is exactly the same code as this one : https://gist.github.com/FireController1847/c7a50144f45806a996d13efcff468d1b.

Edited by dylandmrl
solved
Link to comment
Share on other sites

1 hour ago, dylandmrl said:

bus=Mod.EventBusSubscriber.Bus.MOD

AttachCapabilityEvent doesn't fire on the Mod Event Bus. It fires on the Forge Event Bus.

  • Thanks 1

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

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.

Announcements



×
×
  • Create New...

Important Information

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