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.

Announcements



×
×
  • Create New...

Important Information

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