Skip to content

Commit 824ce91

Browse files
authored
1.21.4 Support (#38)
* feat: 1.21.4 * feat: world events generator (#36) * fix: include default light emission again (#37) * chore: bump to 1.21.4
1 parent 726130e commit 824ce91

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

DataGenerator/src/main/java/net/minestom/datagen/DataGenType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ public enum DataGenType {
2323
FEATURE_FLAGS("feature_flags", new FeatureFlagGenerator()),
2424
FLUIDS("fluids", new FluidGenerator()),
2525
GAME_EVENTS("game_events", new GameEventGenerator()),
26+
WORLD_EVENTS("world_events", new WorldEventGenerator()),
2627
MATERIALS("items", new MaterialGenerator()),
2728
MAP_COLORS("map_colors", new MapColorGenerator()),
2829
PARTICLES("particles", new ParticleGenerator()),

DataGenerator/src/main/java/net/minestom/generators/BlockGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,8 @@ private void writeState(ResourceLocation location, Block block, BlockState block
131131
if (location.toString().equals("minecraft:light")) {
132132
// This is a bad special case for light blocks. minecraft:light[level=0] has an emission value of 0, but the default
133133
// state has an emission value of 15 meaning if this is omitted light 0 will have an emission of 15.
134-
appendState(blockJson, state, "lightEmission", blockState.getLightEmission(), 15, int.class);
134+
// Switch to include it no matter what in this case.
135+
appendState(blockJson, state, "lightEmission", blockState.getLightEmission(), int.class);
135136
} else {
136137
appendState(blockJson, state, "lightEmission", blockState.getLightEmission(), 0, int.class);
137138
}

DataGenerator/src/main/java/net/minestom/generators/MaterialGenerator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public JsonObject generate() {
6262
// Spawn egg properties
6363
if (item instanceof SpawnEggItem spawnEggItem) {
6464
JsonObject spawnEggProperties = new JsonObject();
65-
spawnEggProperties.addProperty("entityType", entityTypeRegistry.getKey(spawnEggItem.getType(ItemStack.EMPTY)).toString());
65+
spawnEggProperties.addProperty("entityType", entityTypeRegistry.getKey(spawnEggItem.getType(registryAccess, ItemStack.EMPTY)).toString());
6666
itemJson.add("spawnEggProperties", spawnEggProperties);
6767
}
6868

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package net.minestom.generators;
2+
3+
import com.google.gson.JsonArray;
4+
import com.google.gson.JsonElement;
5+
import com.google.gson.JsonObject;
6+
import net.minecraft.core.registries.BuiltInRegistries;
7+
import net.minecraft.world.entity.ai.attributes.RangedAttribute;
8+
import net.minecraft.world.level.block.LevelEvent;
9+
import net.minestom.datagen.DataGenerator;
10+
11+
import java.lang.reflect.Modifier;
12+
13+
public final class WorldEventGenerator extends DataGenerator {
14+
@Override
15+
public JsonArray generate() {
16+
JsonArray worldEvents = new JsonArray();
17+
18+
try {
19+
for (var field : LevelEvent.class.getDeclaredFields()) {
20+
if ((field.getModifiers() & Modifier.STATIC) == 0) continue;
21+
if (!field.getType().equals(int.class)) continue;
22+
if (!field.getName().equals(field.getName().toUpperCase())) continue;
23+
24+
int id = field.getInt(null);
25+
String name = field.getName().toLowerCase();
26+
JsonObject worldEvent = new JsonObject();
27+
worldEvent.addProperty("name", name);
28+
worldEvent.addProperty("id", id);
29+
worldEvents.add(worldEvent);
30+
}
31+
} catch (Throwable e) {
32+
throw new RuntimeException(e);
33+
}
34+
35+
return worldEvents;
36+
}
37+
}

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ metadata.format.version = "1.1"
22

33
[versions]
44
gson = "2.10.1"
5-
minecraft = "1.21.3"
5+
minecraft = "1.21.4"
66

77
slf4j-api = "2.0.7"
88
logback = "1.4.5"

0 commit comments

Comments
 (0)