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.