Jump to content

Recommended Posts

Posted

I'm trying to get into modding and am looking at this code here as an example, but when I get to

public void preInit(FMLPreInitializationEvent event)
{
	logger = event.getModLog();
	System.out.print("Called event handler PreInit");
}

 

Eclipse tells me that there is an error with event.getModLog(), saying "The method getModLog() from the type FMLPreInitializationEvent refers to the missing type Logger". How can I fix this?

 

Edit for clarity: I do have import java.util.logging.Logger in my  import statements.

 

EDIT AFTER RESOLUTION: I don't know what shenanigans Eclipse pulled, but one of the quick-fix options that I hadn't tried before, "fix setup," automagically fixed the problem.

<signature></signature>

Posted

Minecraft uses log4j (

org.apache.logging.log4j.Logger

), not

java.util.logging.Logger

.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

If you've set up your ForgeGradle workspace and IDE properly, you should already have log4j as a dependency. Just delete the

java.util.logging.Logger

import and replace it with a

org.apache.logging.log4j.Logger

import.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

If you've set up your ForgeGradle workspace and IDE properly, you should already have log4j as a dependency. Just delete the

java.util.logging.Logger

import and replace it with a

org.apache.logging.log4j.Logger

import.

 

I thought I did, but it doesn't seem to be a valid import; Eclips says that "

The import org.apache cannot be resolved

"

 

 

<signature></signature>

Posted

If you've set up your ForgeGradle workspace and IDE properly, you should already have log4j as a dependency. Just delete the

java.util.logging.Logger

import and replace it with a

org.apache.logging.log4j.Logger

import.

 

I thought I did, but it doesn't seem to be a valid import; Eclips says that "

The import org.apache cannot be resolved

"

 

I suggest running

gradlew setupDecompWorkspace eclipse

again to set up the ForgeGradle workspace and recreate the Eclipse project.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Run it in the folder where I have my Eclipse workspace, right?

 

Run it in the directory where build.gradle is.

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Nothing seems to have changed; I can see

log4l-api-2.0-beta9.jar

and

log4j-core-2.0-beta9.jar

in Forge's

Referenced Libraries

folder, but the import in my project still has the same error. I also noticed that there is a second error message at the top of the file saying "

The type org.apache.log4j.Logger cannot be resolved. It is indirectly referenced from required .class files

" Do I need to do something with my build path?

<signature></signature>

Posted

I'm not too sure what's going wrong.

 

Can you access classes from other referenced libraries (e.g.

com.google.common.collect.ImmutableSet

from Guava or

org.apache.commons.lang3.ArrayUtils

from Apache Commons)?

Please don't PM me to ask for help. Asking your question in a public thread preserves it for people who are having the same problem in the future.

Posted

Sorry for the double-post bit I had a thought: could the problem be related to the fact that I'm using Eclipse EE?

 

No, I use that on some computers.

 

There are a few things that could be going for you:

1) On slower computers, sometimes the IDE takes a while to figure out everything. If you think about what the IDE is doing it is pretty amazing that it can do the real-time warnings -- it literally has to parse all the code in the file, figure out the context, follow imports if needed, etc. So maybe your computer just needs time to catch up. Maybe right-click on the project hierarchy and refresh the project, or also look at the build path settings.

2) Typographical error. Just takes one character wrong to make the computer declare a mis-match. I usually have Eclipse set to update imports automatically upon save. So I would delete all the imports and have them re-populated by Eclipse. In the cases where there are multiple possibilities then it should prompt you for which one you want.

3) Something got screwed up in the project. Try re-running the gradlew setupDecompWorkspace and gradlew eclipse commands again. If that doesn't work, maybe start fresh -- download Forge, set it up and take the example project and try to simply add the logger.

4) If all else fails, try another computer.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.