ForestryMC / ForestryMC

Source code for Forestry (Minecraft mod).
https://forestryforminecraft.info/
Other
479 stars 228 forks source link

[1.11.2] Several Forestry plugins don't load #1816

Closed LachimHeigrim closed 5 years ago

LachimHeigrim commented 7 years ago

In the alpha build #165 some of the Forestry plugins do not load. I noticed the issue originally with #155.

The plugins I use and failed to load are:

The only plugin that seemed to load successfully is Immersive Engineering. No message appears in the log and I can indeed autofarm Industrial Hemp Seeds in multi-farm.

Despite the mods being present and working, the log contains the following:

[20:17:43] [Client thread/INFO] [forestry]: Recreating all gamemode definitions from the defaults. This may be caused by an upgrade
[20:17:43] [Client thread/INFO] [forestry]: Plugin Mystical Agriculture Plugin failed to load: Mystical Agriculture not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin EnderIO Plugin failed to load: EnderIO not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin Natura Plugin failed to load: Natura not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin BuildCraft 6 Statements Plugin failed to load: Compatible BuildCraftAPI|statements version not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin ExtraUtilities Plugin failed to load: ExtraUtilities not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin Chisel Plugin failed to load: Chisel not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin BuildCraft 6 Fuels Plugin failed to load: Compatible BuildCraftAPI|fuels version not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin IndustrialCraft2 Plugin failed to load: IndustrialCraft2 not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin Roots Plugin failed to load: Roots not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin Actually Additions Plugin failed to load: Actually Additions not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin Better With Mods Plugin failed to load: Better With Mods not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin BuildCraft 6 Recipes Plugin failed to load: Compatible BuildCraftAPI|recipes version not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin malisisdoors Plugin failed to load: Malisis Door's not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin BiomesOPlenty Plugin failed to load: BiomesOPlenty not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin HarvestCraft Plugin failed to load: HarvestCraft not found
[20:17:43] [Client thread/INFO] [forestry]: Plugin BuildCraft 6 Transport Plugin failed to load: buildcrafttransport not found

I am able to reproduce the issue just with Natura + Forestry so it does not seem to be caused by larger cross-mod conflict.

Versions:

Forge: Issue discovered with 1.11.2-13.20.1.2386. I am able to reproduce also with newest non-dev Forge version 1.11.2-13.20.1.2425

LachimHeigrim commented 7 years ago

Folks, I'm digging in the code with the intention to make the plugins work and send you a pull request. However it feels like I'll have to deal with some well-bleached skeletons before getting there. :)

If someone could clarify for me: 1) Seems extending BlankForestryPlugin was the old way of doing things. Extending the CompatPlugin is the new & cleaner way? 2) In commented-out sections it seems both BoP & Natura plugins used to register their saplings for autofarming via inter-mod message add-farmable-sapling. I presume this was because both plugins used to be maintained outside of Forestry codebase and could not communicate directly with IFarmRegistry. There is no more code in 1.11.2 branch handling the add-farmable-sapling message and plugins became part of Forestry codebase, i.e. they can now directly register their saplings for farming using IFarmRegistry.registerFarmables(). I see Rustic & ImmersiveEngineering plugins do this. Am I getting the approach right? 3) Is there any FarmableXXX class for farmArboretum to auto-farm modded saplings? Seems both FarmableVanillaSapling and FarmableGE are NOT intended for modded saplings, e.g. one cannot override leaf drops (e.g. Natura's darkwood drops potash apples). Is there any other class that I overlooked? Should I subclass and write my own (reusable for other mods) e.g FarmableModdedTree?

Your insight and guidance is much appreciated.

mezz commented 7 years ago
  1. BlankForestryPlugin is for stuff internal to Forestry. CompatPlugin are for things depending on external mods.
  2. Some of these plugins have been cleaned up a lot in 1.12. Sending IMC to ourselves is silly I agree.
  3. See the 1.12 branch for improved farmable saplings.
LachimHeigrim commented 7 years ago

Thanks @mezz. I should have checked 1.12 myself. Looking at PluginNatura and FarmableSapling it appears you've done most of the work already. I try to backport with minimum changes instead of reinventing the wheel. Got it compiled with few changes but for now recipes are not getting registered; from what I'm seeing the event handler is never triggered. I'll try to figure it out.

LachimHeigrim commented 7 years ago

In 1.11.2 the registry events are fired BEFORE preInit(). The plugins, e.g. PluginNatura are however being instantiated during preInit phase. So registering to the event bus in PluginNatura constructor as you've done in 1.12 won't work: events have already been fired before we even register on the bus.

Schooner's post here confirms the behavior I'm seeing in debugger. Unfortunately I failed googling any confirmation in in official Forge docs.

So I see two options going forward:

  1. Ignore events and preserve the older mechanics where PluginManager calls plugins' registerRecipes() explicitly from PluginManager.runInit(). While less cool than events it seems straightforward, semi-consistent with older versions of Forestry and will need only changes in plugin code.
  2. Rely on events and rewrite plugin instantiation mechanics so that it happens before Forestry.preInit() so that plugins can register to event bus in their constructor. I don't feel too confident doing such refactoring tbh and it seems waste of time since from 1.12 Forge seems to work properly.

Additionally I noticed the Nether saplings - Darkwood, Fusewood and Ghostwood don't work with the auto-farm as they can't be planted on humus. They can be planted on dirt, netherrack or soul sand. I think a good way to handle this is allowing, e.g. netherrack as soil for FarmLogicArboreal. I've raised #1827 for this as it affect 1.12 independently. Also I haven't looked yet if Natura glowshrooms can be farmed using auto-farm.

Let me know what you guys think so that I don't take the wrong path.

mezz commented 7 years ago

I think option 1 sounds like the best choice. We already have it working on 1.12, and 1.11.2 is not gaining a lot of players, so I think you should choose the simpler option. For features like supporting the nether saplings, please target 1.12 first and backport to 1.11.2 if you want it there too.