{"action":"created","issue":{"url":"https://api.github.com/repos/MinecraftForge/FML/issues/646","labels_url":"https://api.github.com/repos/MinecraftForge/FML/issues/646/labels{/name}","comments_url":"https://api.github.com/repos/MinecraftForge/FML/issues/646/comments","events_url":"https://api.github.com/repos/MinecraftForge/FML/issues/646/events","html_url":"https://github.com/MinecraftForge/FML/issues/646","id":70203651,"number":646,"title":"Event subscribtions in complete class hierarchy","user":{"login":"rubensworks","id":440384,"avatar_url":"https://avatars.githubusercontent.com/u/440384?v=3","gravatar_id":"","url":"https://api.github.com/users/rubensworks","html_url":"https://github.com/rubensworks","followers_url":"https://api.github.com/users/rubensworks/followers","following_url":"https://api.github.com/users/rubensworks/following{/other_user}","gists_url":"https://api.github.com/users/rubensworks/gists{/gist_id}","starred_url":"https://api.github.com/users/rubensworks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubensworks/subscriptions","organizations_url":"https://api.github.com/users/rubensworks/orgs","repos_url":"https://api.github.com/users/rubensworks/repos","events_url":"https://api.github.com/users/rubensworks/events{/privacy}","received_events_url":"https://api.github.com/users/rubensworks/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-04-22T18:39:48Z","updated_at":"2015-04-24T16:58:16Z","closed_at":"2015-04-24T05:44:40Z","body":"While writing some event listener abstractions I noticed that the annotations @SubscribeEvent and @Mod.EventHandler are only checked inside the class of the object registered in the event bus.\r\nI was wondering if it would be somehow possible to allow for these annotations on all methods in the complete class hierarchy of these registered event listeners?"},"comment":{"url":"https://api.github.com/repos/MinecraftForge/FML/issues/comments/95991968","html_url":"https://github.com/MinecraftForge/FML/issues/646#issuecomment-95991968","issue_url":"https://api.github.com/repos/MinecraftForge/FML/issues/646","id":95991968,"user":{"login":"heldplayer","id":1283085,"avatar_url":"https://avatars.githubusercontent.com/u/1283085?v=3","gravatar_id":"","url":"https://api.github.com/users/heldplayer","html_url":"https://github.com/heldplayer","followers_url":"https://api.github.com/users/heldplayer/followers","following_url":"https://api.github.com/users/heldplayer/following{/other_user}","gists_url":"https://api.github.com/users/heldplayer/gists{/gist_id}","starred_url":"https://api.github.com/users/heldplayer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/heldplayer/subscriptions","organizations_url":"https://api.github.com/users/heldplayer/orgs","repos_url":"https://api.github.com/users/heldplayer/repos","events_url":"https://api.github.com/users/heldplayer/events{/privacy}","received_events_url":"https://api.github.com/users/heldplayer/received_events","type":"User","site_admin":false},"created_at":"2015-04-24T16:58:16Z","updated_at":"2015-04-24T16:58:16Z","body":"To clarify, the ASM transformer only runs on classes extending my base mod class, and is used to prevent methods with only super calls.\r\n\r\nHowever, take for example this example case:\r\n`ModBase.java`\r\n```java\r\npublic class ModBase {\r\n    // Methods and fields that mods need\r\n\r\n    @EventHandler\r\n    public void preInit(FMLPreInitializationEvent event) {\r\n        // Initialize and set up some values\r\n    }\r\n\r\n    public abstract String getSpecificThing();\r\n}\r\n```\r\n`ModTest.java`\r\n```java\r\n@Mod(modid = \"inheritTest\")\r\npublic class ModTest extends ModBase {\r\n    @EventHandler\r\n    public void init(FMLInitializationEvent event) {\r\n        // Use methods and fields from parent class\r\n    }\r\n\r\n    @Override\r\n    public String getSpecificThing() {\r\n        return \"this thing\";\r\n    }\r\n}\r\n```\r\n\r\nIn this case, you'd want the ModTest class to have the preInit method be executed so that it can use whatever it makes ready for use in its init method. However, to achieve this effect you would have to write the ModTest class to be:\r\n```java\r\n@Mod(modid = \"inheritTest\")\r\npublic class ModTest extends ModBase {\r\n    @Override\r\n    @EventHandler\r\n    public void preInit(FMLPreInitializationEvent event) {\r\n        super.preInit(event);\r\n    }\r\n\r\n    @EventHandler\r\n    public void init(FMLInitializationEvent event) {\r\n        // Use methods and fields from parent class\r\n    }\r\n\r\n    @Override\r\n    public String getSpecificThing() {\r\n        return \"this thing\";\r\n    }\r\n}\r\n```\r\n\r\nThe method \"getSpecificThing\" gets used by the parent class to prepare the values it needs and can be/do anything.\r\n\r\nYou would however also want to have the ability to override the methods to use a custom implementation. For example:\r\n\r\n```java\r\n@Mod(modid = \"inheritTest\")\r\npublic class ModTest extends ModBase {\r\n    @Override\r\n    @EventHandler\r\n    public void preInit(FMLPreInitializationEvent event) {\r\n        // Do other cool stuff and possibly call the super function\r\n    }\r\n\r\n    @EventHandler\r\n    public void init(FMLInitializationEvent event) {\r\n        // Use methods and fields from parent class\r\n    }\r\n\r\n    @Override\r\n    public String getSpecificThing() {\r\n        return \"this thing\";\r\n    }\r\n}\r\n```"}}