First pass at allowing addons to register/remove ore veins#173
Merged
serenibyss merged 12 commits intomasterfrom Dec 15, 2021
Merged
First pass at allowing addons to register/remove ore veins#173serenibyss merged 12 commits intomasterfrom
serenibyss merged 12 commits intomasterfrom
Conversation
TechLord22
reviewed
Oct 16, 2021
905e899 to
88b9a2c
Compare
9dbba47 to
71d6bd0
Compare
71d6bd0 to
05c3b7f
Compare
83dae28 to
82e0634
Compare
TechLord22
approved these changes
Dec 15, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What:
This PR attempts to add method for addon mods to register/remove ore vein definitions and easily add/remove files to the gregtech worldgen folder.
For this, a few new helper variables were introduced:
definitionMapis aMap<String, OreDepositDefinition>with the keys being the relative path from theworldgenfolder in the gregtech config folder to a registered definition, with no leading separator. This is essentiallyOreDepositDefinition.getDepositName(). The values in this map are the registered ore definitionsremovedDefinitionsis a list of all definitions that have been marked for removal by addon mods.addonRegisteredVeinsis a list of all definitions registered from addon mods viaaddVeinDefinitions()Removing existing veins
To remove existing veins, addon mods simply need to call
removeVeinDefinitions(OreDepositDefinition definition)after Gregtech has initialized its own ore veins and the ore definition at the existing path will be removed if there is a matching definition inregisteredDefinitions.The addon mod then needs to call
WorldGenRegistry#reinitializeRegisteredVeins()to delete the file from the existing world gen folder.An example of this would be adding the following lines in
GregTechMod.javaafter the WorldGenRegistry has been initialized at line 160.It should be noted that this should and will fail if a modpack maker removes the existing definition, or changes the filename away from what the addon mod expects the name to be.
I am considering making
registeredDefinitionspublic, so that addon mods can easily get to the list of all registered definitions so that they can easily pass the definition to the remove method. I would like some feedback on this.Adding new veins
To add new veins, addon mods will have to pass the
OreDepositDefinitiontoWorldGenRegistry#addVeinDefintions(OreDepositDefinition definition)either before GTCEu does its vein initialization (This needs testing, it is just my hypothesis right now), which should not require a call toWorldGenRegistry#reinitializeRegisteredVeins(), or after GTCEu has initialized its veins and then callWorldGenRegistry#reinitializeRegisteredVeins().The approach that I took for this method does enforce that
OreDepositDefinition.depositNameneeds to be the relative path from theworldgenfolder to the definition file with no leading separator.As a note, addon mods will not be able to add veins to the same file location as existing ore definitions.
This does bring up a point that I want to try and enforce as a bit of organization however. Addon mods registering veins should add all the veins that they register to a new folder in the
worldgenfolder in the gregtech config file named after their mod id, and then with subfolders for the different dimensions. This will make it much easier for modpack makers to see which veins are being added by the various addon mods.Outcome:
Allow addon mods to easily register their own ore veins and provide a method for addon mods to remove existing ore vein definitions.