Skip to content

Commit

Permalink
Merge pull request #105 from OneLiteFeatherNET/bugfix/wrong-sended-ga…
Browse files Browse the repository at this point in the history
…me-and-biome-tags

Fix wrong mapped meta tags for the client and via version
  • Loading branch information
TheMeinerLP authored Jan 2, 2025
2 parents d698dd3 + 9393286 commit 2335b0e
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ tasks {
addStringOption("-release", "21")
// Links to external javadocs
links("https://docs.oracle.com/en/java/javase/21/docs/api/")
links("https://jd.adventure.kyori.net/api/${libs.versions.adventure.get()}/")
links("https://jd.advntr.dev/api/${libs.versions.adventure.get()}/")
}
}
withType<Zip> {
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/net/minestom/server/game/GameEventImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/
record GameEventImpl(Registry.GameEventEntry registry, NamespaceID namespace, int id) implements GameEvent {
private static final AtomicInteger INDEX = new AtomicInteger();
private static final Registry.Container<GameEvent> CONTAINER = Registry.createStaticContainer(Registry.Resource.GAMEPLAY_TAGS, GameEventImpl::createImpl);
private static final Registry.Container<GameEvent> CONTAINER = Registry.createStaticContainer(Registry.Resource.GAME_EVENTS, GameEventImpl::createImpl);

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

/**
Expand Down
18 changes: 9 additions & 9 deletions src/main/java/net/minestom/server/gamedata/tags/Tag.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.util.Collections;
import java.util.HashSet;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.function.Function;
Expand Down Expand Up @@ -91,23 +90,24 @@ public NamespaceID getName() {

public enum BasicType {
BLOCKS("minecraft:block", Registry.Resource.BLOCK_TAGS,
name -> Optional.ofNullable(Block.fromNamespaceId(name)).map(Block::id)),
blockName -> Optional.ofNullable(Block.fromNamespaceId(blockName)).map(Block::id)),
ITEMS("minecraft:item", Registry.Resource.ITEM_TAGS,
name -> Optional.ofNullable(Material.fromNamespaceId(name)).map(Material::id)),
itemName -> Optional.ofNullable(Material.fromNamespaceId(itemName)).map(Material::id)),
FLUIDS("minecraft:fluid", Registry.Resource.FLUID_TAGS,
name -> Optional.ofNullable(Fluid.fromNamespaceId(name)).map(Fluid::id)),
fluidName -> Optional.ofNullable(Fluid.fromNamespaceId(fluidName)).map(Fluid::id)),
BIOMES("minecraft:worldgen/biome", Registry.Resource.BIOME_TAGS,
biomeName -> Optional.of(DynamicRegistry.Key.of(biomeName)).map(DynamicRegistry.Key::namespace).map(MinecraftServer.getBiomeRegistry()::getId)),
ENTITY_TYPES("minecraft:entity_type", Registry.Resource.ENTITY_TYPE_TAGS,
name -> Optional.ofNullable(EntityType.fromNamespaceId(name)).map(EntityType::id)),
entityName -> Optional.ofNullable(EntityType.fromNamespaceId(entityName)).map(EntityType::id)),
GAME_EVENTS("minecraft:game_event", Registry.Resource.GAMEPLAY_TAGS,
name -> Optional.ofNullable(EntityType.fromNamespaceId(name)).map(EntityType::id)),
eventName -> Optional.ofNullable(GameEvent.fromNamespaceId(eventName)).map(GameEvent::id)),
SOUND_EVENTS("minecraft:sound_event", null, null), // Seems not to be included in server data
POTION_EFFECTS("minecraft:sound_event", null, null), // Seems not to be included in server data

//todo this is cursed. it does not update as the registry changes. Fix later.
ENCHANTMENTS("minecraft:enchantment", Registry.Resource.ENCHANTMENT_TAGS,
name -> Optional.of(DynamicRegistry.Key.of(name)).map(DynamicRegistry.Key::namespace).map(MinecraftServer.getEnchantmentRegistry()::getId)),;
enchName -> Optional.of(DynamicRegistry.Key.of(enchName)).map(DynamicRegistry.Key::namespace).map(MinecraftServer.getEnchantmentRegistry()::getId)),;

private final static BasicType[] VALUES = values();
private static final BasicType[] VALUES = values();
private final String identifier;
private final Registry.Resource resource;
private final Function<String, Optional<Integer>> function;
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/minestom/server/registry/Registry.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ public enum Resource {
ENTITY_TYPE_TAGS("tags/entity_type.json"),
FLUID_TAGS("tags/fluid.json"),
GAMEPLAY_TAGS("tags/game_event.json"),
GAME_EVENTS("game_events.json"),
BIOME_TAGS("tags/biome.json"),
ITEM_TAGS("tags/item.json"),
ENCHANTMENT_TAGS("tags/enchantment.json"),
DIMENSION_TYPES("dimension_types.json"),
Expand Down Expand Up @@ -562,7 +564,7 @@ public boolean hasPrecipitation() {
}
}

public static final record GameEventEntry(NamespaceID namespace, Properties main, Properties custom) implements Entry {
public record GameEventEntry(NamespaceID namespace, Properties main, Properties custom) implements Entry {
public GameEventEntry(String namespace, Properties main, Properties custom) {
this(NamespaceID.from(namespace), main, custom);
}
Expand Down

0 comments on commit 2335b0e

Please sign in to comment.