Error when exporting with certain mod export names

Published by Matrillex on
Issue description

When I try and export a mod with MCreator 1.8.0 for 1.12.2

Problematic mod element list
Recomplation has failed because complier found errors.

 

D:\forge\build\sources\main\java\mod\mcreator\sword.java:35: error: cannot find symbol
    mcreator_sword mcreator_0 = new mcreator_sword();
    ^
  symbol:   class mcreator_sword
  location: class sword
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

This seems to happen with every mod I make regardless of how I set it up.Deleting and reinstalling MCreator then setting the mod up the exact same way fixes it but when I try and make a second mod of any kind the problem comes up again meaning I seem to only be able to make one mod per MCreator installation, which from my understanding means I can never use the recipe option to make a recipe for a modded item. 

Issue comments

This error should be able to be fixed by switching to another workspace and back to the first one, you don't need to do the full reinstall.

Could you please provide me the exact steps how do you manage to get this error after you fix it by reinstalling? Thanks!

I've tried switching workshops but the problem comes right back up. As for how I got the error I've noticed that doing anything will cause it. I've tried making multiple mods multiple ways including only adding what is required to press the next button but the mod will still come up as error. One thing I recall is I made a custom block which worked, then I made a second that only changed the texture used and when I tried to export it it said the first mod was broken and wouldn't let me export the second mod. I also remember making four new blocks and 2 recipes per block and getting the error but I don't think it pointed any mod out as being the problem. I managed to make somewhat progress by making one block separately but in order to do the next I'd have to completely delete and reinstall MCreator. I would try changing the workshop but the very first mod made in that workshop would have an error; which is why I mentioned every second mod I make would come up with this error. I'll get a step by step of every single thing I do in a few minutes, I gotta delete and reinstall as like mentioned before; the error is persistent beyond workshops.

Oh and another thing; before it was bugging at the second mod it was working and letting me do more than one mod at a time; can't remember how consistent it was then though. Might have been every third or fourth mod that malfunctioned. 

(Using Archive) New MCreator 1.8.0 installed in (D:) custom folder as to not conflict another Mcreator in (D:)

Create New Element (left block selected)
Name: Test (T auto capitalized)
         OK
Click box in blue outlines
Import block texture
Selects texture from desktop
Clicks texture
Select
          Next
Name in GUI: test
          Next
          Next
          Next
          Next
          Next
Export
Name of mod: test
Recompile and Export
Agree
selects folder on desktop
name: test; saved as .jar
Sucsess 

Create New Element (left block selected)
Name: Test2 (T auto capitalized)
         OK
Click box in blue outlines
Import block texture
Selects texture from desktop
Clicks texture
Select
          Next
Name in GUI: test2
          Next
          Next
          Next
          Next
          Next
Export
Name of mod: test2
Recompile and Export
Error

Also the error seems slightly different but following the same steps result in the same problem, varying steps can include more distinct names, changing the mod version, or setting more up for the mod. Also changing the workshop and following the EXACT steps for what made it work the first time will result in the error and trying to go back after swapping doesn't seem to have an effect either; hence why I mentioned that changing workshops does not resolve the problem. 

D:\Here\forge\build\sources\main\java\mod\mcreator\mcreator_test.java:29: error: class mcreator_test2 is public, should be declared in a file named mcreator_test2.java
public class mcreator_test2 {
       ^
D:\Here\forge\build\sources\main\java\mod\mcreator\test2.java:35: error: cannot find symbol
    mcreator_test mcreator_0 = new mcreator_test();
    ^
  symbol:   class mcreator_test
  location: class test2
D:\Here\forge\build\sources\main\java\mod\mcreator\test2.java:35: error: cannot find symbol
    mcreator_test mcreator_0 = new mcreator_test();
                                   ^
  symbol:   class mcreator_test
  location: class test2
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
3 errors

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

It will generally flag the first mod made as the problem and selecting the option to remove the problematic mod will sometimes delete that first mod if anything. But then trying to export will once again not work and I got this error
 

D:\Here\forge\build\sources\main\java\mod\mcreator\tt.java:35: error: cannot find symbol
    mcreator_test2 mcreator_0 = new mcreator_test2();
    ^
  symbol:   class mcreator_test2
  location: class tt
1 error

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

Based on the fact that switching the workspace does not fix this error, is there option to share the workspace and attach it to this ticket so I can investigate it? Thanks!

Alrighty; best of luck. I'll try and see if I can figure anything out in the meantime. I have a theory that it might be conflicting with something else on my computer (since I assume no one else has reported this issue and I don't believe I am doing anything wrong for say) so later I'll look at putting it on a computer without anything to see if that has any effects.

Thanks. Your very detailed description has made it possible for me to make a replicate of this bug on my computer. As I am able to replicate this bug, I will do my best to fix this bug. I will keep you updated here if I manage to find out more about this issue.

For now, I can confirm, this is not an issue with your computer, but a MCreator bug. As this bug breaks workspace, I am rising priority of this bug to major.

This error is caused if any of the words that appear in the code is used when exporting the mod. You made a block called Test, so there was a word Test in your code. When exporting the mod, this is replaced and causes compile errors. This error corrupts workspace and is very problematic in this aspect and is very hard to predict, so I am rising the priority of this ticket to critical.

Critical level means next release will be on hold until this gets resolved.

I have fixed this issue. The bug fix for this issue will be released in 1.8.1. For now, avoid using mod names (when exporting the complete mod) that could appear in the code.

Sorry for the late reply, got busy with things. Glad to know the error was resolved!