Skip to content
Merged
4 changes: 4 additions & 0 deletions DataGenerator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ application {
mainClass.set("net.minestom.datagen.DataGen")
}

tasks.run {
args = arrayListOf(rootDir.resolve("src/main/resources/net/minestom/data").absolutePath)
}

java {
sourceCompatibility = JavaVersion.VERSION_25
targetCompatibility = JavaVersion.VERSION_25
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package net.minestom.datagen;

import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.world.clock.ClockTimeMarkers;
import net.minestom.generators.*;
import net.minestom.generators.loot_tables.BlockLootTableGenerator;
import net.minestom.generators.loot_tables.ChestLootTableGenerator;
Expand All @@ -27,6 +28,8 @@ public enum DataGenType {
SOUND_SOURCES("sound_sources", new SoundSourceGenerator()),
VILLAGER_TYPES("villager_types", new GenericRegistryArrayGenerator<>(BuiltInRegistries.VILLAGER_TYPE)),
BLOCK_ENTITY_TYPES("block_entity_types", new GenericRegistryObjectGenerator<>(BuiltInRegistries.BLOCK_ENTITY_TYPE)),
CLOCK_TIME_MARKERS("clock_time_marker", new ClockTimeMarkerGenerator()),
GAME_RULES("game_rule", new GameRuleGenerator()),

// Static registries

Expand All @@ -48,9 +51,12 @@ public enum DataGenType {
BANNER_PATTERNS("banner_pattern", new GenericResourceGenerator("banner_pattern")),
BIOMES("worldgen/biome", new GenericResourceGenerator("worldgen/biome")),
CAT_VARIANTS("cat_variant", new GenericResourceGenerator("cat_variant")),
CAT_SOUND_VARIANTS("cat_sound_variant", new GenericResourceGenerator("cat_sound_variant")),
CHAT_TYPES("chat_type", new GenericResourceGenerator("chat_type")),
CHICKEN_VARIANTS("chicken_variant", new GenericResourceGenerator("chicken_variant")),
CHICKEN_SOUND_VARIANTS("chicken_sound_variant", new GenericResourceGenerator("chicken_sound_variant")),
COW_VARIANTS("cow_variant", new GenericResourceGenerator("cow_variant")),
COW_SOUND_VARIANTS("cow_sound_variant", new GenericResourceGenerator("cow_sound_variant")),
DAMAGE_TYPES("damage_type", new GenericResourceGenerator("damage_type")),
DIALOGS("dialog", new GenericResourceGenerator("dialog")),
DIMENSION_TYPES("dimension_type", new GenericResourceGenerator("dimension_type")),
Expand All @@ -60,12 +66,14 @@ public enum DataGenType {
INSTRUMENTS("instrument", new GenericResourceGenerator("instrument")),
PAINTING_VARIANTS("painting_variant", new GenericResourceGenerator("painting_variant")),
PIG_VARIANTS("pig_variant", new GenericResourceGenerator("pig_variant")),
PIG_SOUND_VARIANTS("pig_sound_variant", new GenericResourceGenerator("pig_sound_variant")),
TIMELINE("timeline", new GenericResourceGenerator("timeline")),
TRIM_MATERIALS("trim_material", new GenericResourceGenerator("trim_material")),
TRIM_PATTERNS("trim_pattern", new GenericResourceGenerator("trim_pattern")),
WOLF_VARIANTS("wolf_variant", new GenericResourceGenerator("wolf_variant")),
WOLF_SOUND_VARIANTS("wolf_sound_variant", new GenericResourceGenerator("wolf_sound_variant")),
ZOMBIE_NAUTILUS_VARIANTS("zombie_nautilus_variant", new GenericResourceGenerator("zombie_nautilus_variant")),
WORLD_CLOCKS("world_clock", new GenericResourceGenerator("world_clock")),

// Loot tables (only included for legacy reasons, Minestom doesn't use them)

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.*;
import java.util.stream.Collectors;

public final class BlockGenerator extends DataGenerator {
@Override
Expand Down Expand Up @@ -82,18 +83,12 @@ public JsonObject generate() {
state.addProperty("stateId", Block.BLOCK_STATE_REGISTRY.getId(bs));
writeState(location, block, blockSoundTypes, bs, blockJson, state);

StringBuilder stateName = new StringBuilder("[");
for (var propertyEntry : bs.getValues().entrySet()) {
if (stateName.length() > 1) {
stateName.append(",");
}
stateName.append(propertyEntry.getKey().getName().toLowerCase(Locale.ROOT))
.append("=")
.append(propertyEntry.getValue().toString().toLowerCase(Locale.ROOT));
}
stateName.append("]");
//[property=value,property2=value2,...]
String stateName = bs.getValues()
.map(v -> v.toString().toLowerCase(Locale.ROOT))
.collect(Collectors.joining(",", "[", "]"));

blockStates.add(stateName.toString(), state);
blockStates.add(stateName, state);
}
blockJson.add("states", blockStates);
blocks.add(location.toString(), blockJson);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package net.minestom.generators;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.clock.ClockTimeMarker;
import net.minecraft.world.clock.ClockTimeMarkers;
import net.minestom.datagen.DataGenerator;

import java.lang.reflect.Field;

public class ClockTimeMarkerGenerator extends DataGenerator {

@Override
@SuppressWarnings("unchecked")
public JsonElement generate() throws Exception {
JsonObject markers = new JsonObject();
for (Field declaredField : ClockTimeMarkers.class.getDeclaredFields()) {
if (declaredField.getType() != ResourceKey.class) continue;
ResourceKey<ClockTimeMarker> marker = (ResourceKey<ClockTimeMarker>) declaredField.get(null);
// I'm expecting this to become a dynamic registry at some point.
markers.add(marker.identifier().toString(), new JsonObject());
}
return markers;
}
}

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package net.minestom.generators;

import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.core.registries.Registries;
import net.minecraft.resources.ResourceKey;
import net.minecraft.world.clock.ClockTimeMarker;
import net.minecraft.world.clock.ClockTimeMarkers;
import net.minestom.datagen.DataGenerator;

import java.lang.reflect.Field;

public class GameRuleGenerator extends DataGenerator {

@Override
public JsonElement generate() throws Exception {
JsonObject markers = new JsonObject();
for (var gameRule : BuiltInRegistries.GAME_RULE) {
var ruleJson = new JsonObject();
ruleJson.addProperty("id", BuiltInRegistries.GAME_RULE.getId(gameRule));
ruleJson.addProperty("default", String.valueOf(gameRule.defaultValue()));
ruleJson.addProperty("type", gameRule.gameRuleType().getSerializedName());
markers.add(gameRule.getIdentifier().toShortString(), ruleJson);
}
return markers;
}
}
5 changes: 1 addition & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ tasks.register("generateData") {
logger.warn("The data may or may not be the intellectual property of Mojang Studios.")
logger.warn("")

// Simplified by Sponge's VanillaGradle
dependsOn(project(":DataGenerator").tasks.getByName<JavaExec>("run") {
args = arrayListOf(rootDir.resolve("src/main/resources/net/minestom/data").absolutePath)
})
dependsOn(project(":DataGenerator").tasks.getByName("run"))
}

tasks.processResources.get().dependsOn("generateData")
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ metadata.format.version = "1.1"

[versions]
gson = "2.13.2"
minecraft = "26.1-snapshot-11"
minecraft = "26.1"

slf4j-api = "2.0.17"
logback = "1.5.22"

loom = "1.14-SNAPSHOT"
loom = "1.15-SNAPSHOT"
nmcp = "1.3.0"

[libraries]
Expand Down