Regenerating Code Deletes Core Files (Help Request)

Started by Mindthemoods on

Topic category: Help with MCreator software

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Regenerating Code Deletes Core Files (Help Request)
Thu, 07/13/2023 - 03:33 (edited)

After updating to the latest Patch, attempting to compile one of my mods results in the majority of the mod elements giving compilation errors such as the following:

C:\Users\prcri\MCreatorWorkspaces\superiorstructures\src\main\java\net\mcreator\superiorstructures\procedures\MansionFrontWingProcedure.java:13: error: cannot find symbol 
import net.mcreator.superiorstructures.init.SuperiorstructuresModGameRules; 
                                           ^ 
  symbol:   class SuperiorstructuresModGameRules 
  location: package net.mcreator.superiorstructures.init
C:\Users\prcri\MCreatorWorkspaces\superiorstructures\src\main\java\net\mcreator\superiorstructures\init\SuperiorstructuresModEntities.java:117: error: cannot find symbol 
   public static final RegistryObject<EntityType<EnergyRail2Entity>> ENERGY_RAIL_2 = register("projectile_energy_rail_2", 
                                                 ^ 
  symbol:   class EnergyRail2Entity 
  location: class SuperiorstructuresModEntities
C:\Users\prcri\MCreatorWorkspaces\superiorstructures\src\main\java\net\mcreator\superiorstructures\block\LaserBeamHalfBlock.java:43: error: cannot find symbol 
import net.mcreator.superiorstructures.procedures.LaserBeamUpdateTickProcedure; 
                                                 ^ 
  symbol:   class LaserBeamUpdateTickProcedure 
  location: package net.mcreator.superiorstructures.procedures

Overall about 90% of the Mod elements are giving said errors. Regenerating the code causes the number to vary, but it usually remains about the same. However, updating other mods to the latest patch does not result in this issue. (That being said, this is my largest mod, at around 2,300 elements, along with a lot of locked code, structure, and texture files.) The Editor mostly works fine, but some elements cannot be opened, and many are either missing their thumbnail or have the wrong thumbnail displayed.

...Weirdly, this also isn't the first time this particular mod has done this. The last time this issue came up, (updating from 2023.1 to an earlier version of 2023.2), I was able to open a backup in the previous version; but the pre-patch version is no longer available, and I overwrote it instead of deleting it when I downloaded the new version. It seems like the mod is missing a bunch of important main-components, but I'm really not sure how to resolve this issue, and have tried quite a few different courses of action.

Opening the src files reveals that there are quite a few java files missing in the broken workspace. Restoring these files seems to help, (to a point). However, there are also several important 'init' files missing, including the ModItems and ModRenders files, which even when restored are deleted upon regeneration. (Trying to compile after restoring these prompts me to regenerate the workspace, deleting them again, and causing the same problem.) However, compiling after these are restored results in a bunch of 'Missing Package' errors saying that the package for the ModItems file doesn't exist.

I'll keep updating this if I make any progress; I'm curious if anyone has a similar issue.

 

Edited by Mindthemoods on Thu, 07/13/2023 - 03:33
Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Upon further research,…
Mon, 06/26/2023 - 05:11

Upon further research, pretty sure I need to just delete and regenerate caches. ...Here's hoping for the best.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I've tried all the solutions…
Mon, 06/26/2023 - 15:39

I've tried all the solutions suggested for this problem, as per these instructions, but the problem remains unchanged. I cleared the Cache files, the Gradle file, and even tried regenerating the entire .mcreator user file, but nothing seems to resolve the issue. 

Are these instructions outdated? I noticed there's now an option to automatically clear caches/reload the gradle while in the workspace instead of deleting them manually. Whatever the case, any help would be appreciated!

Did you try to perform…
Tue, 06/27/2023 - 17:01

Did you try to perform reboots between those actions? This is a crucial part of instructions most users miss.

Reboot releases potential locks on the files you remove

You may also need to reload gradle project from build menu to get it to work

Keep in mind in most cases…
Tue, 06/27/2023 - 17:01

Keep in mind in most cases this error is caused by antivirus in the first place, so I would highly recommend adding <user home>/.mcreator/gradle to the antivirus exceptions

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Got it, I’ll definitely give…
Wed, 06/28/2023 - 19:58

Got it, I’ll definitely give it another try. I have been rebooting between steps and reloading the grade project, but nothing so far. I suspect it may have something to do with antivirus though, will try that too. 

Do you recommend reloading the workspace from backups before trying this? I have a full backup from before updating, but it seems to cause the same issue.

Anyways, thanks for the help! I’m always pleasantly surprised with how supportive the forum is. 

The workspace itself is not…
Thu, 06/29/2023 - 16:18

The workspace itself is not broken. If you copied workspace to another computer and built it there it would work as gradle caches are global and not per workspace

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
I think I've found a…
Mon, 07/10/2023 - 03:40

I think I've found a solution. Also, I think the problem either wasn't what I initially thought, or possibly changed somewhere along the way.

I tried basically everything I could think of to clear the gradle cache, including loading the workspace on another computer. Once again, it was only this workspace that caused the missing symbol errors. I figured something must be wrong with this specifically, so I dug through the supposedly missing files. I found, firstly, that the main java files were still there- but a bunch of the files for specific blocks and items were missing. Trying to open the mod elements with missing java files did nothing, even if the missing files were copied from a backup into their respective locations and the workspace reloaded.

I did some more experimentation, and eventually found that unlocking certain locked procedures and elements significantly reduced the number of errors. After comparing the post and pre-regenerated files, I noticed that the ones causing compilation errors were referencing a 'ModGamerules' package that wasn't referenced in the regenerated versions, and other procedures that referenced things using the broken reference. Unlocking and relocking these, or manually deleting the "import net.mcreator.[modname].init.SuperiorstructuresModGamerules;' line fixes their specific errors.

I haven't yet fully fixed the workspace, and there's still the matter of the handful of components that are totally missing and unopenable, but it's progress. I suspect the gradle may have initially been corrupted, (there were originally a fluctuating number of compilation errors,  it's stable now), but somewhere along the way something else went wrong. I'm genuinely curious at this point if someone's having a similar issue, as I'm way out of my depth at this point, but glad to have found something that seems to work.

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
...And another update, it…
Mon, 07/10/2023 - 17:45

...And another update, it seems like I was able to fix everything by opening an older backup in 2023.1! I was also able to load in the src and save files from the newer version with minimal tweaking, and thusfar haven't encountered anything gamebreaking.

I'm still at a total loss for what was wrong in the first place, but all's well that ends well I guess. If anyone has a similar issue, I recommend, (first of all), copying your mod into a new workspace and then opening that in the new version FIRST, on the off chance things go catastrophically wrong; and, (secondly), if, (like me), you have a limited knowledge of java; just opening a backup and hoping for the best before spending multiple weeks messing around with source files.

 

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
While I was briefly able to…
Wed, 07/12/2023 - 03:15

While I was briefly able to get the mod working , the same issue came up again shortly thereafter. At this point I'm starting to lose my marbles a bit.

I checked through the source files again, and found that quite a few files that were present in previous backups, (Including the LaserBeamUpdateTick procedure, EnergyRailEntity, and ModGameRules file; were missing in the new version.

By manually restoring these files from backups, I was able to reduce build errors. However, this seemed to cause further 'cannot find package' errors, such as:

C:\Users\prcri\MCreatorWorkspaces\superiorstructuresreboot\src\main\java\net\mcreator\superiorstructures\world\inventory\TransceiverInterfaceMenu.java:81: error: package SuperiorstructuresModItems does not exist 
            return SuperiorstructuresModItems.TRANSPONDER.get() == stack.getItem();

...After restoring the missing ModItems file and Transponder files. 

In edition, most of the restored files seemed to be deleted again whenever the code is regenerated. While the missing files are consistent, (the same files are missing when the code is regenerated), there isn't really any pattern to which files are missing; in total it seems about a hundred java files. 

I'm way out of my depth at this point and worried I'm going to break things further. At this point I have tried:

  • Clearing and regenerating the global cache, gradle, and .mcreator files
  • Loading backups in older versions of Mcreator
  • Reinstalling various versions of Mcreator
  • Manually unlocking all locked elements. (Reduces compilation errors, but does not resolve issue.)
  • Manually restoring various missing files. (Also reduces compilation errors, but does not resolve issue.)

Advice?

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
It's the same for most of…
Wed, 07/12/2023 - 20:31

It's the same for most of the workspace. I checked through the src, and there are a bunch of files present in backups that aren't present in the broken version, including init files; about a hundred total across all of src/main/java/net/mcreator/superiorstructures. 

But manually restoring the missing files from the backups causes the 'missing package' error, and the backup workspaces themselves have the same problem.

...Regenerating the gradle/caches doesn't do anything, and other workspaces still function normally, so I think it's something to do with the workspace, but reloading backups also doesn't fix the problem, leading me to think whatever regenerates the code is causing issues, or deleting these java files for some reason. The compilation errors sit around 1800, but can be reduced down to about 800 by manually restoring files and unlocking things- but everything reverts whenever the code is regenerated.

I'm also using the Geckolib plugin, not sure if that's relevant.

Would sharing the workspace zip/full error log help?

Big workspaces with locked…
Thu, 07/13/2023 - 16:35

Big workspaces with locked files and manual moves of elements are pretty hard / close to impossible to check especially by another person not knowing the workspace well

Joined May 2022
Points:

User statistics:

  • Modifications:
  • Forum topics:
  • Wiki pages:
  • MCreator plugins:
  • Comments:
Agreed. I've been able to…
Fri, 07/14/2023 - 02:41

Agreed. I've been able to manually fix most of the errors by restoring missing files and fixing a few broken references. The remaining errors seem to all be more or less as follows:

C:\Users\prcri\MCreatorWorkspaces\superiorstructuresreboot\src\main\java\net\mcreator\superiorstructures\item\PhaseItem.java:47: error: package SuperiorstructuresModItems does not exist 
            return Ingredient.of(new ItemStack(SuperiorstructuresModItems.RAW_ENDORITE.get()), new ItemStack(Items.POPPED_CHORUS_FRUIT)); 
                                                                         ^ 
C:\Users\prcri\MCreatorWorkspaces\superiorstructuresreboot\src\main\java\net\mcreator\superiorstructures\procedures\AutomaticTeleportProcedure.java:45: error: package SuperiorstructuresModItems does not exist 
      if ((entity instanceof LivingEntity _entGetArmor ? _entGetArmor.getItemBySlot(EquipmentSlot.HEAD) : ItemStack.EMPTY).getItem() == SuperiorstructuresModItems.PHASE_HELMET.get() && amount > 1) { 
                                                                                                                                                                  ^ 
C:\Users\prcri\MCreatorWorkspaces\superiorstructuresreboot\src\main\java\net\mcreator\superiorstructures\procedures\BoltBlaster2FiredProcedure.java:42: error: package SuperiorstructuresModItems does not exist 
               ItemStack _setstack = new ItemStack(SuperiorstructuresModItems.DEACTIVATED_BOLT_BLASTER_2.get()); 
                                                                             ^ 
C:\Users\prcri\MCreatorWorkspaces\superiorstructuresreboot\src\main\java\net\mcreator\superiorstructures\procedures\BoltBlaster3FiredProcedure.java:42: error: package SuperiorstructuresModItems does not exist 
               ItemStack _setstack = new ItemStack(SuperiorstructuresModItems.DEACTIVATED_BOLT_BLASTER_3.get());

...And so on and so forth for several hundred errors, all similar. I've manually restored the 'SuperiorstructuresModItems' file to the src, and it's imported in 'SuperiorstructuresMod.' Is there somewhere else the ModItems files might have been deleted or referenced? 

Could you check mcreator.log…
Fri, 07/14/2023 - 13:14

Could you check mcreator.log and link the log somewhere? Something is preventing the file from generating properly