From 7ab434abf4231ede54e393cc459ce7373f2d0a17 Mon Sep 17 00:00:00 2001 From: Matyrobbrt Date: Fri, 24 Jan 2025 13:09:38 +0200 Subject: [PATCH] Rename data map --- .../world/entity/npc/VillagerType.java.patch | 2 +- ...ome_villagers.json => villager_types.json} | 0 .../internal/NeoForgeDataMapsProvider.java | 6 ++-- ...meVillager.java => BiomeVillagerType.java} | 12 ++++---- .../datamaps/builtin/NeoForgeDataMaps.java | 28 +++++++++---------- 5 files changed, 24 insertions(+), 24 deletions(-) rename src/generated/resources/data/neoforge/data_maps/worldgen/biome/{biome_villagers.json => villager_types.json} (100%) rename src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/{BiomeVillager.java => BiomeVillagerType.java} (53%) diff --git a/patches/net/minecraft/world/entity/npc/VillagerType.java.patch b/patches/net/minecraft/world/entity/npc/VillagerType.java.patch index 6b09c51c7e..9c50d4c224 100644 --- a/patches/net/minecraft/world/entity/npc/VillagerType.java.patch +++ b/patches/net/minecraft/world/entity/npc/VillagerType.java.patch @@ -13,7 +13,7 @@ } public static VillagerType byBiome(Holder p_204074_) { -+ var fromDataMap = p_204074_.getData(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.BIOME_VILLAGERS); ++ var fromDataMap = p_204074_.getData(net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps.VILLAGER_TYPES); + if (fromDataMap != null) return fromDataMap.type(); + // TODO - 1.22: remove fallback return p_204074_.unwrapKey().map(BY_BIOME::get).orElse(PLAINS); diff --git a/src/generated/resources/data/neoforge/data_maps/worldgen/biome/biome_villagers.json b/src/generated/resources/data/neoforge/data_maps/worldgen/biome/villager_types.json similarity index 100% rename from src/generated/resources/data/neoforge/data_maps/worldgen/biome/biome_villagers.json rename to src/generated/resources/data/neoforge/data_maps/worldgen/biome/villager_types.json diff --git a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java index 13f8d00171..5a5a588e4c 100644 --- a/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java +++ b/src/main/java/net/neoforged/neoforge/common/data/internal/NeoForgeDataMapsProvider.java @@ -40,7 +40,7 @@ import net.minecraft.world.level.storage.loot.LootTable; import net.neoforged.fml.util.ObfuscationReflectionHelper; import net.neoforged.neoforge.common.data.DataMapProvider; -import net.neoforged.neoforge.registries.datamaps.builtin.BiomeVillager; +import net.neoforged.neoforge.registries.datamaps.builtin.BiomeVillagerType; import net.neoforged.neoforge.registries.datamaps.builtin.Compostable; import net.neoforged.neoforge.registries.datamaps.builtin.FurnaceFuel; import net.neoforged.neoforge.registries.datamaps.builtin.MonsterRoomMob; @@ -58,9 +58,9 @@ public NeoForgeDataMapsProvider(PackOutput packOutput, CompletableFuture, VillagerType>, VillagerType>getPrivateValue(VillagerType.class, null, "BY_BIOME") - .forEach((biome, type) -> biomeVillagers.add(biome, new BiomeVillager(type), false)); + .forEach((biome, type) -> biomeVillagers.add(biome, new BiomeVillagerType(type), false)); final var compostables = builder(NeoForgeDataMaps.COMPOSTABLES); final List villagerCompostables = ObfuscationReflectionHelper.getPrivateValue(WorkAtComposter.class, null, "COMPOSTABLE_ITEMS"); diff --git a/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillager.java b/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillagerType.java similarity index 53% rename from src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillager.java rename to src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillagerType.java index 559315e978..dfe281fd29 100644 --- a/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillager.java +++ b/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillagerType.java @@ -11,15 +11,15 @@ import net.minecraft.world.entity.npc.VillagerType; /** - * Data map value for {@linkplain NeoForgeDataMaps#BIOME_VILLAGERS biome villagers}. + * Data map value for {@linkplain NeoForgeDataMaps#VILLAGER_TYPES biome villager types}. * * @param type the type of the villagers present in this biome */ -public record BiomeVillager(VillagerType type) { - public static final Codec TYPE_CODEC = BuiltInRegistries.VILLAGER_TYPE.byNameCodec() - .xmap(BiomeVillager::new, BiomeVillager::type); - public static final Codec CODEC = Codec.withAlternative( +public record BiomeVillagerType(VillagerType type) { + public static final Codec TYPE_CODEC = BuiltInRegistries.VILLAGER_TYPE.byNameCodec() + .xmap(BiomeVillagerType::new, BiomeVillagerType::type); + public static final Codec CODEC = Codec.withAlternative( RecordCodecBuilder.create(in -> in.group( - BuiltInRegistries.VILLAGER_TYPE.byNameCodec().fieldOf("villager_type").forGetter(BiomeVillager::type)).apply(in, BiomeVillager::new)), + BuiltInRegistries.VILLAGER_TYPE.byNameCodec().fieldOf("villager_type").forGetter(BiomeVillagerType::type)).apply(in, BiomeVillagerType::new)), TYPE_CODEC); } diff --git a/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/NeoForgeDataMaps.java b/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/NeoForgeDataMaps.java index b0ae6a2b1e..502243b3c5 100644 --- a/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/NeoForgeDataMaps.java +++ b/src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/NeoForgeDataMaps.java @@ -38,19 +38,6 @@ * synced so that mods can use them on the client side. */ public class NeoForgeDataMaps { - /** - * The {@linkplain Biome} data map that replaces {@link VillagerType#BY_BIOME}. - *

- * The location of this data map is {@code neoforge/data_maps/biome/biome_villagers.json}, and the values are objects with 1 field: - *

    - *
  • {@code villager_type}, villager type ID - the type of the villagers present in the biome
  • - *
- * - * The use of a string as the value is also possible, though discouraged in case more options are added in the future. - */ - public static final DataMapType BIOME_VILLAGERS = DataMapType.builder( - id("biome_villagers"), Registries.BIOME, BiomeVillager.CODEC).synced(BiomeVillager.TYPE_CODEC, false).build(); - /** * The {@linkplain Item} data map that replaces {@link ComposterBlock#COMPOSTABLES}. *

@@ -143,6 +130,19 @@ public class NeoForgeDataMaps { public static final DataMapType VIBRATION_FREQUENCIES = DataMapType.builder( id("vibration_frequencies"), Registries.GAME_EVENT, VibrationFrequency.CODEC).synced(VibrationFrequency.FREQUENCY_CODEC, false).build(); + /** + * The {@linkplain Biome} data map that replaces {@link VillagerType#BY_BIOME}. + *

+ * The location of this data map is {@code neoforge/data_maps/worldgen/biome/villager_types.json}, and the values are objects with 1 field: + *

    + *
  • {@code villager_type}, villager type ID - the type of the villagers present in the biome
  • + *
+ * + * The use of a string as the value is also possible, though discouraged in case more options are added in the future. + */ + public static final DataMapType VILLAGER_TYPES = DataMapType.builder( + id("villager_types"), Registries.BIOME, BiomeVillagerType.CODEC).synced(BiomeVillagerType.TYPE_CODEC, false).build(); + /** * The {@linkplain Block} data map that replaces {@link HoneycombItem#WAXABLES}. *

@@ -162,7 +162,6 @@ private static ResourceLocation id(final String name) { @SubscribeEvent private static void register(final RegisterDataMapTypesEvent event) { - event.register(BIOME_VILLAGERS); event.register(COMPOSTABLES); event.register(FURNACE_FUELS); event.register(MONSTER_ROOM_MOBS); @@ -170,6 +169,7 @@ private static void register(final RegisterDataMapTypesEvent event) { event.register(PARROT_IMITATIONS); event.register(RAID_HERO_GIFTS); event.register(VIBRATION_FREQUENCIES); + event.register(VILLAGER_TYPES); event.register(WAXABLES); } }