Skip to content

Commit 5761dcb

Browse files
committed
Add better mapping for meta tags for client
(cherry picked from commit 93ea3b9)
1 parent 30a2bb9 commit 5761dcb

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

src/main/java/net/minestom/server/game/GameEventImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*/
1818
record GameEventImpl(Registry.GameEventEntry registry, NamespaceID namespace, int id) implements GameEvent {
1919
private static final AtomicInteger INDEX = new AtomicInteger();
20-
private static final Registry.Container<GameEvent> CONTAINER = Registry.createStaticContainer(Registry.Resource.GAMEPLAY_TAGS, GameEventImpl::createImpl);
20+
private static final Registry.Container<GameEvent> CONTAINER = Registry.createStaticContainer(Registry.Resource.GAME_EVENTS, GameEventImpl::createImpl);
2121

2222
/**
2323
* Creates a new {@link GameEventImpl} with the given namespace and properties.
@@ -36,7 +36,7 @@ private static GameEventImpl createImpl(String namespace, Registry.Properties pr
3636
* @param registry the registry
3737
*/
3838
private GameEventImpl(Registry.GameEventEntry registry) {
39-
this(registry, registry.namespace(), INDEX.getAndIncrement());
39+
this(registry, registry.namespace(), registry.main().getInt("id"));
4040
}
4141

4242
/**

src/main/java/net/minestom/server/gamedata/tags/Tag.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import net.minestom.server.registry.ProtocolObject;
1313
import net.minestom.server.registry.Registry;
1414
import net.minestom.server.utils.NamespaceID;
15+
import net.minestom.server.world.biome.Biome;
1516
import org.jetbrains.annotations.Contract;
1617
import org.jetbrains.annotations.NotNull;
1718
import org.jetbrains.annotations.Nullable;
@@ -96,10 +97,12 @@ public enum BasicType {
9697
name -> Optional.ofNullable(Material.fromNamespaceId(name)).map(Material::id)),
9798
FLUIDS("minecraft:fluid", Registry.Resource.FLUID_TAGS,
9899
name -> Optional.ofNullable(Fluid.fromNamespaceId(name)).map(Fluid::id)),
100+
BIOMES("minecraft:worldgen/biome", Registry.Resource.BIOME_TAGS,
101+
name -> Optional.of(DynamicRegistry.Key.of(name)).map(DynamicRegistry.Key::namespace).map(MinecraftServer.getBiomeRegistry()::getId)),
99102
ENTITY_TYPES("minecraft:entity_type", Registry.Resource.ENTITY_TYPE_TAGS,
100103
name -> Optional.ofNullable(EntityType.fromNamespaceId(name)).map(EntityType::id)),
101104
GAME_EVENTS("minecraft:game_event", Registry.Resource.GAMEPLAY_TAGS,
102-
name -> Optional.ofNullable(EntityType.fromNamespaceId(name)).map(EntityType::id)),
105+
name -> Optional.ofNullable(GameEvent.fromNamespaceId(name)).map(GameEvent::id)),
103106
SOUND_EVENTS("minecraft:sound_event", null, null), // Seems not to be included in server data
104107
POTION_EFFECTS("minecraft:sound_event", null, null), // Seems not to be included in server data
105108

src/main/java/net/minestom/server/registry/Registry.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,8 @@ public enum Resource {
245245
ENTITY_TYPE_TAGS("tags/entity_type.json"),
246246
FLUID_TAGS("tags/fluid.json"),
247247
GAMEPLAY_TAGS("tags/game_event.json"),
248+
GAME_EVENTS("game_events.json"),
249+
BIOME_TAGS("tags/biome.json"),
248250
ITEM_TAGS("tags/item.json"),
249251
ENCHANTMENT_TAGS("tags/enchantment.json"),
250252
DIMENSION_TYPES("dimension_types.json"),
@@ -562,7 +564,7 @@ public boolean hasPrecipitation() {
562564
}
563565
}
564566

565-
public static final record GameEventEntry(NamespaceID namespace, Properties main, Properties custom) implements Entry {
567+
public record GameEventEntry(NamespaceID namespace, Properties main, Properties custom) implements Entry {
566568
public GameEventEntry(String namespace, Properties main, Properties custom) {
567569
this(NamespaceID.from(namespace), main, custom);
568570
}

0 commit comments

Comments
 (0)