Closed newtykip closed 3 months ago
I think before going through the effort of writing and adapting the data extractor(s) for multiple MC versions, we should look into existing alternatives. The block state list is relatively easy to get, Mojang even provides a tool themselves, or otherwise possibly pixlyzer or preferably ArcticData (see the blocks and their properties) could be used.
The entity NBT structure is sadly not as easy to get and the current method is also far from flawless. The only two strategies I can really think of are:
Neither is perfect. The main issue I see with the wiki route is it only being for the most recent MC version. For the source parsing we need info about all entity classes (currently part of the DataExtractor's job), but that at least seems to be partially available in pixlyzer but not in ArcticData (to be fair, this is dependent on the mappings used, yarn vs official).
Even apart from all that, I feel like the entire list stuff of the crate could do with a rewrite. (And docs are obviously needed, but that's besides the point)
These are just some thoughts, and before I commit to anything, it would be great to get some feedback :smile:
The wiki is pretty much immediately out of the question, and if we are going to have to make a data extractor then shouldn't we just get the block state directly from it ourselves as well? That's dead simple compared to the entity data. For ease of use, we can download client jars and deobfuscation maps using the launcher's version manifest and grab the necessary dependencies for deobfuscation as follows (SpecialSource 1.10.0 should be good enough)
As for deobfuscation, why did you also try to use Fernflower? I never had any issues with CFR. If Fernflower had a use that has just flown past me, then setting that up will be a tad harder as we have to first clone the repository and then run gradlew build
and grab the output from build/libs/fernflower.jar
. CFR 0.152 is easy enough.
Maybe there is a smarter way that neither of us is noticing at first glance though because this does seem clunky. But not all problems have elegant solutions.
A kind of janky but functional alternative I thought of is that you could always just use the latest Minecraft version's data and use ArticData's lists to choose which things to export. However, the reason this is janky is that there may be useless NBT fields or ones that have been renamed (idk if this has ever happened?)
Could be something we could work off of though?
Sorry for not responding earlier.
if we are going to have to make a data extractor then shouldn't we just get the block state directly from it ourselves as well? That's dead simple compared to the entity data.
true
For ease of use, we can download client jars and deobfuscation maps using the launcher's version manifest and grab the necessary dependencies for deobfuscation as follows [...]
I actually kinda like the current fabric mod approach, it already handles all the dependency stuff. I don't see why we should change that.
As for deobfuscation, why did you also try to use Fernflower? I never had any issues with CFR.
I always had one or two classes that the java-parser (used in the source-parser) couldn't parse as valid java code, so I used the FernFlower decompilation as a fallback which worked so far:
If Fernflower had a use that has just flown past me, then setting that up will be a tad harder as we have to first clone the repository and then run
gradlew build
and grab the output frombuild/libs/fernflower.jar
. CFR 0.152 is easy enough.
Again, using a fabric mod setup handles it all for us.
Maybe there is a smarter way that neither of us is noticing at first glance though because this does seem clunky. But not all problems have elegant solutions.
Who knows :shrug:
Anyways, I've started work locally on rewriting the data extraction from scratch, intending to use the same strategies already used. I currently only have the block state list extraction, but that for all major Minecraft versions since 1.14.4 using three slightly different DataExtractor
classes. To generate mod templates for the different versions, I depend on the same code as the Fabric CLI tools. That means I also use Deno instead of NodeJS. The code to run it all is now also written in Rust instead of Bash and will become an xtask.
DataExtractor
number)DataExtractor
number 2One additional complication I stumbled upon is the introduction of experimental features in 1.19.3. This includes blocks, for which this is easily detected and the info is already saved in the blocks.json
, but it can also be used for anything else. For instance, since 1.20 Mob heads placed on note blocks play the respective mod sound, but this feature was introduces experimentally in 1.19.3, so the extraction output from 1.19.3 lists these sounds for the NoteBlockInstrument
property, and this can not easily be detected from code. (Note that ArcticData also includes these in the 1.19.3 data). I think the right way to go about this is to have these things included in the appropriate rustmatica feature because they are in the game and schematics from the version could include them, but we should also document the fact that they were still experimental. Or what do you think?
I will probably push a new branch relatively soon with my current progress.
I honestly have no idea why I thought we needed the client jars in that initial comment, we really don't. So I'm just going to ignore the fact I spoke about that and blame it on a lack of sleep 💀
Upon reflection, I think I was waffling about automating fetching the source code for the java parser and getting decompilers ready But I don't know why I was talking about the client jars, you need the yarn mappings anyway. I dunno what I was on.
Was FernFlower also not good enough on its own? Did that still leave a couple of faulty classes?
Anywho, I agree with your approach to experimental features, and the implementation details seem rugged. Good work so far (:
Was FernFlower also not good enough on its own? Did that still leave a couple of faulty classes?
Yes, either one on its own didn't suffice, but using both did.
Anywho, I agree with your approach to experimental features, and the implementation details seem rugged. Good work so far (:
Good!
Just to let you know, I've actually finally gotten back to working on this and have found a very promising way to get the entity NBT structure. It's now also a separate crate called mcdata
as it isn't strictly just useful for rustmatica
. I hope to get a new version of rustmatica
with mcdata
support released somewhat soon.
I believe I can close this now. rustmatica
now uses mcdata
and also finally has some documentation: https://docs.rs/rustmatica/ :tada:
Create versions of the
DataExtractor
for various versions of Minecraft so that we can provide feature flags that provide all of the relevant blocks for a given version of Minecraft - also update the litematica schematic where relevant if necessary.