Jump to content

Coremod troubles (1.5.2)


NuclearFej

Recommended Posts

Hey everyone.

 

My problem probably isn't that hard to those of you with more experience than I. My coremod works just fine in Eclipse/MCP. How do I release it?

 

I've created META-INF/MANIFEST.MF, it points to a dummy loader class (which implements IFMLLoadingPlugin, of course) which in turn points to the main mod class. I get a duplicate, though, as the @Mod annotation is still in there. I can see that it is replaced by the methods in the interface ModContainer, so I'm comfortable with getting rid of it, but what about the @NetworkMod annotation? How do I implement that in a coremod? I need to be able to point to my packet handler.

 

But do tell me if I'm wrong - in a coremod, you don't use the @Mod, @NetworkMod or @Instance annotations, right? What about @Init, @PreInit, etc?

 

Besides that, what do I need to do that Forge already does for you in a non-coremod?

 

(Additionally, I get exceptions when I run the mod outside of MCP; this may or may not be related. I don't know.)

 

Thanks for your help guys!

Link to comment
Share on other sites

Thanks for the help guys!

 

Unfortunately from that problem comes three more..

 

1. It does not load in Eclipse anymore. How can I fix it so that it will?

 

The mod itself does load in the Minecraft client, the registerBus method is called as well as all of the initialization events, but...

 

2. If you click on the mod's name under the Mods menu, the game crashes with this stacktrace:

 

 

2013-08-01 18:40:21 [iNFO] [sTDERR] net.minecraft.util.ReportedException: Rendering screen
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1030)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:871)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.Minecraft.run(Minecraft.java:760)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at java.lang.Thread.run(Unknown Source)
2013-08-01 18:40:22 [iNFO] [sTDERR] Caused by: java.lang.NullPointerException
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.gui.FontRenderer.func_78259_e(SourceFile:645)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.gui.FontRenderer.func_78280_d(SourceFile:632)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.gui.FontRenderer.func_78271_c(SourceFile:628)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.gui.FontRenderer.func_78268_b(SourceFile:604)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.gui.FontRenderer.func_78279_b(SourceFile:600)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at cpw.mods.fml.client.GuiModList.func_73863_a(GuiModList.java:171)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1021)
2013-08-01 18:40:22 [iNFO] [sTDERR] 	... 3 more

 

 

as well as this:

 

 

java.lang.NullPointerException
at net.minecraft.client.gui.FontRenderer.func_78259_e(SourceFile:645)
at net.minecraft.client.gui.FontRenderer.func_78280_d(SourceFile:632)
at net.minecraft.client.gui.FontRenderer.func_78271_c(SourceFile:628)
at net.minecraft.client.gui.FontRenderer.func_78268_b(SourceFile:604)
at net.minecraft.client.gui.FontRenderer.func_78279_b(SourceFile:600)
at cpw.mods.fml.client.GuiModList.func_73863_a(GuiModList.java:171)
at net.minecraft.client.renderer.EntityRenderer.func_78480_b(EntityRenderer.java:1021)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:871)
at net.minecraft.client.Minecraft.run(Minecraft.java:760)
at java.lang.Thread.run(Unknown Source)

 

 

3. If I attempt to run singleplayer (haven't tested multiplayer) a field which previously caused no problem (in Eclipse) no longer seems to exist.

 

This is the stacktrace:

 

java.lang.NoSuchFieldError: currentClass
at com.playaimon.Aimon.VanillaControl.FejRecipe.func_77569_a(FejRecipe.java:45)
at net.minecraft.item.crafting.CraftingManager.func_82787_a(CraftingManager.java:306)
at net.minecraft.inventory.ContainerPlayer.func_75130_a(SourceFile:80)
at net.minecraft.inventory.ContainerPlayer.<init>(SourceFile:75)
at net.minecraft.entity.player.EntityPlayer.<init>(EntityPlayer.java:186)
at net.minecraft.entity.player.EntityPlayerMP.<init>(EntityPlayerMP.java:163)
at net.minecraft.server.management.ServerConfigurationManager.func_72366_a(ServerConfigurationManager.java:383)
at net.minecraft.server.integrated.IntegratedServerListenThread.func_71747_b(IntegratedServerListenThread.java:91)
at net.minecraft.server.MinecraftServer.func_71190_q(MinecraftServer.java:677)
at net.minecraft.server.MinecraftServer.func_71217_p(MinecraftServer.java:573)
at net.minecraft.server.integrated.IntegratedServer.func_71217_p(IntegratedServer.java:127)
at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:470)
at net.minecraft.server.ThreadMinecraftServer.run(SourceFile:573)

 

 

Aimon is the name of the mod. currentClass is a field containing an enum type that I created. Why would it not exist? Because it is starting up, perhaps? No, wait, it can't be - the code has a check to make sure that the player isn't null. If the field was merely unpopulated, it would have been a NullPointerException, right?

 

Why does the field not exist? The field is in the EntityPlayer class. Am I not allowed to add fields to Minecraft base classes?

 

Thanks again!

Link to comment
Share on other sites

1.You need a dummy container jar in the coremods folder. See tutorials.

2.Don't know, might be linked with 1., but you may also have left a null in your mod description.

3.You have to decide between editing the classes and making a coremod. Doing both makes no sense.

 

Link to comment
Share on other sites

1.You need a dummy container jar in the coremods folder. See tutorials.

You don't. Use the -Dfml.coreMods.load=MAIN_CLASS VM argument.

2.Don't know, might be linked with 1., but you may also have left a null in your mod description.
The latter. If ModMetadata.description is null that happens.

 

Thank you! Both of those suggestions worked. :D

 

3.You have to decide between editing the classes and making a coremod. Doing both makes no sense.

 

Please tell me if these definitions are wrong (seriously, I'd like to know):

 

Mod: adds new classes, can inject bytecode

Coremod: adds new classes and/or changes existing ones

 

Although isn't the difference more or less history, as in 1.6 they became one and the same?

 

I want to change existing classes. In fact, I have, and it works in Eclipse. What changes between the build environment and the "real world", so to speak?

 

Additionally, why should I not make it a coremod? I don't quite follow, sorry.

 

Thanks for the help, guys!

Link to comment
Share on other sites

 

Please tell me if these definitions are wrong (seriously, I'd like to know):

 

Mod: adds new classes, can inject bytecode

Coremod: adds new classes and/or changes existing ones

 

Although isn't the difference more or less history, as in 1.6 they became one and the same?

 

I want to change existing classes. In fact, I have, and it works in Eclipse. What changes between the build environment and the "real world", so to speak?

 

Additionally, why should I not make it a coremod? I don't quite follow, sorry.

 

Thanks for the help, guys!

Huh, mods aren't supposed to inject bytecode.

Coremods can do anything.

The difference in naming should be kept, because mods are more likely to be compatible between each other, while coremods are just fancy way of editing base classes. Two coremods changing the same thing will probably crash the game, just like two internal mods were.

 

What I meant by this

You have to decide between editing the classes and making a coremod. Doing both makes no sense.

If you made edits into a base class, you have to inject bytecode for all modifications.

You shouldn't do it half-way.

 

Why not a coremod ?

-It will be a real hassle to maintain with Mojang updates

-Compatibility issues, as said previously

-It is usually less efficient than a mod

-Bytecode / ASM is tedious to code and hard to debug

Link to comment
Share on other sites

You have to decide between editing the classes and making a coremod. Doing both makes no sense.

If you made edits into a base class, you have to inject bytecode for all modifications.

You shouldn't do it half-way.

 

Why (and how)? Is it absolutely necessary? I mean, if you can do this:

 

That's not true. The only way to edit base classes without being a coremod is to just replace the whole class.

 

why not avoid bytecode (and therefore being a coremod) alltogether? After all, if

 

-Bytecode / ASM is tedious to code and hard to debug

 

(and I totally believe you) why should I bother with it anyway? I'm not worried about compatibility.

Link to comment
Share on other sites

That's not true. The only way to edit base classes without being a coremod is to just replace the whole class. Of course, if someone else replaces the same class only one edit can persist, unless the two mods work together. With coremods you only change the parts of the class you need to change (maybe even only one or two instructions in one method). If another coremod changes the same class but a different method it works completely fine without the 2 mods knowing about each other.

If what i said is false, why do you agree with me ? You should have read what is said a bit more carefully ;)

I do have a coremod maintained and it's not hard at all.

Well, we may have had a different experience with it.

-It is usually less efficient than a mod
What? Prove this please. Just one counter example: if you need to access a private method with a normal mod you have to use reflection, with a coremod you don't. Reflection is bad for performance.

And bytecode  generation at runtime is worse than reflection, sorry to say.

Link to comment
Share on other sites

You said coremods are just as incompatible with each other as "normal" base-edit mods are. And i disagreed.

No, I didn't, thus we agreed.

Two coremods changing the same thing will probably crash the game, just like two internal mods were.

I never said different. But the reflection code is ran every time you access the field.

The bytecode is only generated once at class-loading time (which is slow anyways) and after that it behaves as if it had been in the class from the beginning.

Yes, of course.

You are only assuming that the changed code will run as efficiently as the original one. I don't.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • https://mclo.gs/4UC49Ao
    • Way back in the Forge 1.17 days, work started for adding JPMS (Java Platform Module Support) to ModLauncher and ForgeModLoader. This has been used internally by Forge and some libraries for a while now, but mods (those with mods.toml specifically) have not been able to take advantage of it. As of Forge 1.21.1 and 1.21.3, this is now possible!   What is JPMS and what does it mean for modders? JPMS is the Java Platform Module System, introduced in Java 9. It allows you to define modules, which are collections of packages and resources that can be exported or hidden from other modules. This allows for much more fine-tuned control over visibility, cleaner syntax for service declarations and support for sealed types across packages. For example, you might have a mod with a module called `com.example.mod` that exports `com.example.mod.api` and `com.example.mod.impl` to other mods, but hides `com.example.mod.internal` from them. This would allow you to have a clean API for other mods to use, while keeping your internal implementation details hidden from IDE hints, helping prevent accidental usage of internals that might break without prior notice. This is particularly useful if you'd like to use public records with module-private constructors or partially module-private record components, as you can create a sealed interface that only your record implements, having the interface be exported and the record hidden. It's also nice for declaring and using services, as you'll get compile-time errors from the Java compiler for typos and the like, rather than deferring to runtime errors. In more advanced cases, you can also have public methods that are only accessible to specific other modules -- handy if you want internal interactions between multiple of your own mods.   How do I bypass it? We understand there may be drama in implementing a system that prevents mods from accessing each other's internals when necessary (like when a mod is abandoned or you need to fix a compat issue) -- after all, we are already modding a game that doesn't have explicit support for Java mods yet. We have already thought of this and are offering APIs from day one to selectively bypass module restrictions. Let me be clear: Forge mods are not required to use JPMS. If you don't want to use it, you don't have to. The default behaviour is to have fully open, fully exported automatic modules. In Java, you can use the `Add-Opens` and `Add-Exports` manifest attributes to selectively bypass module restrictions of other mods at launch time, and we've added explicit support for these when loading your Forge mods. At compile-time, you can use existing solutions such as the extra-java-module-info Gradle plugin to deal with non-modular dependencies and add extra opens and exports to other modules. Here's an example on how to make the internal package `com.example.examplemod.internal` open to your mod in your build.gradle: tasks.named('jar', Jar) { manifest { attributes([ 'Add-Opens' : 'com.example.examplemod/com.example.examplemod.internal' 'Specification-Title' : mod_id, 'Specification-Vendor' : mod_authors // (...) ]) } } With the above in your mod's jar manifest, you can now reflectively access the classes inside that internal package. Multiple entries are separated with a space, as per Java's official spec. You can also use Add-Exports to directly call without reflection, however you'd need to use the Gradle plugin mentioned earlier to be able to compile. The syntax for Add-Exports is the same as Add-Opens, and instructions for the compile-time step with the Gradle plugin are detailed later in this post. Remember to prefer the opens and exports keywords inside module-info.java for sources you control. The Add-Opens/Add-Exports attributes are only intended for forcing open other mods.   What else is new with module support? Previously, the runtime module name was always forced to the first mod ID in your `mods.toml` file and all packages were forced fully open and exported. Module names are now distinguished from mod IDs, meaning the module name in your module-info.java can be different from the mod ID in your `mods.toml`. This allows you to have a more descriptive module name that doesn't have to be the same as your mod ID, however we strongly recommend including your mod ID as part of your module name to aid troubleshooting. The `Automatic-Module-Name` manifest attribute is now also honoured, allowing you to specify a module name for your mod without needing to create a `module-info.java` file. This is particularly useful for mods that don't care about JPMS features but want to have a more descriptive module name and easier integration with other mods that do use JPMS.   How do I use it? The first step is to create a `module-info.java` file in your mod's source directory. This file should be in the same package as your main mod class, and should look something like this: open module com.example.examplemod { requires net.minecraftforge.eventbus; requires net.minecraftforge.fmlcore; requires net.minecraftforge.forge; requires net.minecraftforge.javafmlmod; requires net.minecraftforge.mergetool.api; requires org.slf4j; requires logging; } For now, we're leaving the whole module open to reflection, which is a good starting point. When we know we want to close something off, we can remove the open modifier from the module and open or export individual packages instead. Remember that you need to be open to Forge (module name net.minecraftforge.forge), otherwise it can't call your mod's constructor. Next is fixing modules in Gradle. While Forge and Java support modules properly, Gradle does not put automatic modules on the module path by default, meaning that the logging module (from com.mojang:logging) is not found. To fix this, add the Gradle plugin and add a compile-time module definition for that Mojang library: plugins { // (...) id 'org.gradlex.extra-java-module-info' version "1.9" } // (...) extraJavaModuleInfo { failOnMissingModuleInfo = false automaticModule("com.mojang:logging", "logging") } The automatic module override specified in your build.gradle should match the runtime one to avoid errors. You can do the same for any library or mod dependency that is missing either a module-info or explicit Automatic-Module-Name, however be aware that you may need to update your mod once said library adds one. That's all you need to get started with module support in your mods. You can learn more about modules and how to use them at dev.java.
    • Faire la mise à jour grâce à ce lien m'a aider personnellement, merci à @Paint_Ninja. https://www.amd.com/en/support 
    • When I came across the 'Exit Code: I got a 1 error in my Minecraft mods, so I decided to figure out what was wrong. First, I took a look at the logs. In the mods folder (usually where you'd find logs or crash reports), I found the latest.log file or the corresponding crash report. I read it through carefully, looking for any lines with errors or warnings. Then I checked the Minecraft Forge support site, where you can often find info on what causes errors and how to fix them. I then disabled half of my mods and tried running the game. If the error disappeared, it meant that the problem was with the disabled mod. I repeated this several times to find the problem mod.
    • I have no idea - switch to a pre-configured modpack and use it as working base    
  • Topics

×
×
  • Create New...

Important Information

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