Has @subscribeEvent annotation, but takes an argument that is not a subtype of the base type interface IModBusEvent

Started by AwesomeDomi on

Topic category: Help with modding (Java Edition)

Last seen on 17:56, 19. Apr 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Has @subscribeEvent annotation, but takes an argument that is not a subtype of the base type interface IModBusEvent
Mon, 06/12/2023 - 07:49 (edited)

C:\Users\-\MCreatorWorkspaces\superior_tnt\src\main\java\net\mcreator\superiortnt\SuperiorTNTEventHandler.java:24: error: package net.minecraftforge.event.world does not exist

import net.minecraftforge.event.world.ChunkEvent;
                                                                    ^
C:\Users\-\MCreatorWorkspaces\superior_tnt\src\main\java\net\mcreator\superiortnt\SuperiorTNTEventHandler.java:37: error: package ChunkEvent does not exist

public static void chunkLoaded(ChunkEvent.Load event) {
                                                                              ^
2 errors
FAILURE: Build failed with an exception.

 

I'm getting this error, I'm trying to make an event which will occur whenever a chunk is loaded, but it says the package for ChunkEvent does not exist.

Edited by AwesomeDomi on Mon, 06/12/2023 - 07:49
Are you using custom code?…
Sun, 06/11/2023 - 09:50

Are you using custom code? In this case, make sure the code you are copying is for the right Minecraft version

Last seen on 17:56, 19. Apr 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I managed to fix this part,…
Mon, 06/12/2023 - 07:39

I managed to fix this part, I just had incorrect imports, but now I'm running into a new problem, it says that my chunkLoaded method:

has @subscribeEvent annotation, but takes an argument that is not a subtype of the base type interface net.minecraftforge.fml.event.IModBusEvent: class net.minecraftforge.event.level.ChunkEvent$Load

And this is confusing me because I'm getting help from a friend of mine and he says that he put the same code outside MCreator and it works fine

My method:

@SubscribeEvent
public static void chunkLoaded(Load event) {
System.out.println("New chunk loaded");
}

Yes it's custom code

It fully depends where you…
Mon, 06/12/2023 - 16:47

It fully depends where you put the trigger, whether it is static or not and what event bus it is on.

If you want to do custom code, I suggest learning Forge event system fully first. This may help: https://docs.minecraftforge.net/en/latest/concepts/events/

Last seen on 17:56, 19. Apr 2024
Joined Nov 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It works now, I solved it by…
Wed, 06/14/2023 - 13:11

It works now, I solved it by not using a custom element, and making the class myself.