Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

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

Featured Replies

Posted

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

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.

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.

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.