feat: use https://github.com/misode/mcmeta to replace the old je_block_default_states.json file (it's renamed to je_blocks.json now).

This commit is contained in:
daoge_cmd
2025-08-21 11:51:17 +08:00
parent 757ed6ad4d
commit b7864bb6fb
5 changed files with 24 additions and 3620 deletions

View File

@@ -4,6 +4,6 @@
Current mapping version: je 1.21.7 to be 1.21.93
- `mapping/biomes.json` and `mapping/items.json` obtain from [GeyserMC/mappings](https://github.com/GeyserMC/mappings).
- `mapping/blocks.json` generated by using [GeyserMC/mappings-generator](https://github.com/GeyserMC/mappings-generator), and it's origin name is `new_generator_blocks.json`.
- `je_block_default_states.json` converted from [Block state values](https://zh.minecraft.wiki/w/Module:Block_state_values).
- `mapping/biomes.json` and `mapping/items.json` are obtained from [GeyserMC/mappings](https://github.com/GeyserMC/mappings).
- `mapping/blocks.json` is obtained from [GeyserMC/mappings-generator](https://github.com/GeyserMC/mappings-generator) (path: `https://github.com/GeyserMC/mappings-generator/blob/master/new_generator_blocks.json`).
- `je_blocks.json` is obtained from [misode/mcmeta](https://github.com/misode/mcmeta) (path: `https://github.com/misode/mcmeta/blob/<version>-summary/blocks/data.json`).

View File

@@ -15,6 +15,10 @@ val geyserMappings: Configuration by configurations.register("geyserMappings") {
isCanBeConsumed = false
}
val mcmeta: Configuration by configurations.register("mcmeta") {
isCanBeConsumed = false
}
dependencies {
shadedApi(project(":common:implementation:base"))
@@ -25,6 +29,8 @@ dependencies {
geyserMappings("GeyserMC.mappings", "items", Versions.Allay.mappings, ext = "json")
geyserMappings("GeyserMC.mappings", "biomes", Versions.Allay.mappings, ext = "json")
geyserMappings("GeyserMC.mappings-generator", "new_generator_blocks", Versions.Allay.mappingsGenerator, ext = "json")
mcmeta("misode.mcmeta", "blocks/data", Versions.Allay.mcmeta, ext ="json")
}
tasks.processResources {
@@ -34,4 +40,7 @@ tasks.processResources {
// rather jank, but whatever
rename("(?:new_generator_)?([^-]+)-(.*)\\.json", "$1.json")
}
from(mcmeta) {
rename("data-(.*)\\.json", "je_blocks.json")
}
}

View File

@@ -157,15 +157,21 @@ public final class Mapping {
return true;
}
@SuppressWarnings("unchecked")
private static boolean initJeBlockDefaultProperties() {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_block_default_states.json")) {
try(InputStream stream = Mapping.class.getClassLoader().getResourceAsStream("je_blocks.json")) {
if(stream == null) {
TerraAllayPlugin.INSTANCE.getPluginLogger().error("je_block_default_states.json not found");
return false;
}
Map<String, Map<String, String>> states = from(stream, new TypeToken<>() {});
JE_BLOCK_DEFAULT_PROPERTIES.putAll(states);
Map<String, List<Map<String, ?>>> data = from(stream, new TypeToken<>() {});
for(var entry : data.entrySet()) {
JE_BLOCK_DEFAULT_PROPERTIES.put(
"minecraft:" + entry.getKey(),
(Map<String, String>) entry.getValue().get(1)
);
}
} catch(IOException e) {
throw new RuntimeException(e);
}
@@ -245,7 +251,6 @@ public final class Mapping {
}
}
// see https://stackoverflow.com/questions/59655279/is-there-an-easy-way-to-make-gson-skip-a-field-if-theres-an-error-deserializing
public static class IgnoreFailureTypeAdapterFactory implements TypeAdapterFactory {
@Override

File diff suppressed because it is too large Load Diff