Project-wide refactors/clean-ups, rewrite generators to use Fabric's data generation API#97
Open
eclipseisoffline wants to merge 41 commits into
Open
Project-wide refactors/clean-ups, rewrite generators to use Fabric's data generation API#97eclipseisoffline wants to merge 41 commits into
eclipseisoffline wants to merge 41 commits into
Conversation
…iles, update .gitignore
…enamer to reduce code duplication for renames
…e files that we still manage
… issues (hopefully)
…ap IOExceptions in UncheckedIOException
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.
This PR rewrites Geyser's mappings-generator to make use of Fabric Loom and Fabric's data generator API. With this, all mapping generators have been rewritten to better fit in the modern Minecraft and Java ecosystem. The code has received a broad clean-up and major improvements. PR highlights are:
System.out.printlnstatements, making it easier to identify problems.mappingsdirectory - the previousmappingssubmodule can now be found atmappings/mappings.bedrock-samplesat runtime (unless the current samples are accurate for the current bedrock version).mappingssubmodule if that is not done yet (to be implemented, maybe).All the changes made in this PR will be noted below. A TO-DO list can be found at the end of the description.
Project-wide changes
libs.versions.tomlfile is now used for library management.bedrock-samples.zip, and the task to extract the resourcepack from it, have been removed, as this is now downloaded at runtime.-Dline.separator=\u00aJVM argument is given to therunDatagentask, to ensure the generated files use the same line endings everywhere.mappingssubmodule can now be found under themappingsdirectory, so atmappings/mappings.mappings/palettes.mappingsdirectory as well.additional_offhand_items.jsonhas been removed, as it is now tracked in themappingsrepository.generator_blocks.jsonhas been removed, and its replacement is no longer tracked in VCS..gitattributesand.editorconfigfiles have been added..gitignorehas been updated to reflect the changes in the project structure.Codebase-wide changes
org.geysermc.mappingspackage (wasorg.geysermc.generator).generatoris now a package withinorg.geysermc.mappings(see below) - without this rename, the package name would have beenorg.geysermc.generator.generator, which can be confusing.JsonElements orCompoundTags directly, they can do so by usingMappingsCodecs.JSON_ELEMENTandCompoundTag.CODECrespectively.The root package (
org.geysermc.mappings)The root package contains the core classes of the generator, used all across the codebase.
FileTypeA
FileTypestores a (relative) path to a file, its codec, and its file type (JSON, NBT, or plain text).FileTypes are constants and defined in theFileTyperecord itself. Every file touched by the generator (including files not generated by it, such as palette files) has aFileType1.MappingsAccessAn implementation of the
MappingsAccessinterface represents access to themappingsfolder (NOT the submodule). This interface is a functional one, and has many default methods for reading and writingFileTypes.MappingsGenerator, the abstract base class for all generators, implementsMappingsAccess, allowing the generators to easily access themappingsfolder with its utility methods.MappingsGeneratorsMappingsGeneratorsis the project'sDataGeneratorEntrypoint.MappingsOutputMappingsOutputimplements Mojang'sCachedOutput, and builds further upon it: the class manages thefile_hashes.jsonfile, a JSON file containing the hashes of all the files generated by the generators, which is committed to VCS. Using the hashes in this file,MappingsOutputis able to generate a "files changed" report, which is shown at the end of the generation process.This class also manages deleting old files, which is normally done by
CachedOutput, however, this would also delete files not generated by the current subset of generators, which is not wanted behaviour.MappingsOutputis automatically used for all generators, which is done using mixins.The
definitionspackageThe
definitionspackage holds many data records with codecs, used for reading and writing to files, and building mappings. These records are grouped in packages by the generator(s) that need them.The
generatorpackageThe
generatorpackage holds the abstract base classMappingsGenerator, which implementsMappingsAccessand Mojang'sDataProvider. The package also holds every generator (which all extend the baseMappingsGenerator). These classes generally aren't too long, as the code to generate mappings is also shared with the definitions in thedefinitionspackage, and the renamers in thenamespackage.Generators are further grouped into the
javaclasspackage for Geyser's Java class generators, and themcplpackage for MCPL's generators.The
namespackageThe
namespackage contains hardcoded Java to bedrock renames, used in the generators. These renames are stored in "renamers".The base renamer is the
InstanceRenamerfunctional interface, which functions like the old "block state name override" system: implementations take a typeT(e.g.Block), and return a function turning an instance of typeT(I, e.g.BlockState) into the renamed result (R, usuallyStringorIdentifier). TheTypeRenamerfunctional interface extends on this and is used for instance-independent renames (i.e.T->Rdirectly). BothInstanceRenamerandTypeRenamerhave helper methods and builders for creating renamers.Renamers are kept in the
Renamersclass. For renamers with little code, e.g.Renamers.BIOMES, the code is kept in theRenamersclass itself. For more complicated renamers, the code is kept in a separate class in therenamerschild package, with a reference in theRenamersclass.Other packages
Mixins are kept in the
mixinpackage. As mixins can be complicated to understand, each mixin must have a Javadoc explaining its purpose. Furthermore, theresourcespackage contains classes for automatically downloading and managing resources (for now, onlybedrock-samples.zip). Lastly, theutilpackage contains utility classes, such asFieldConstructor,MappingsUtil, andMappingsCodecs.Generator specific changes
To be described...
Changes to the generated mappings
additional_offhand_items.jsonfile is now tracked in the mappings submodule.typeandparentkeys at the top, then sort alphabetically).interactions.jsonfile now holds theDataVersionfor which it was generated, which allows skipping the generator when the data version hasn't changed.sounds.jsonfile has been cleaned up (empty string mappings have been removed).TO-DOs:
Footnotes
The only exception to this is the
bedrock-samples.zipfile. ↩