-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '1.21.x' into 1.21.x-ShapeUpdateEvent
- Loading branch information
Showing
6 changed files
with
196 additions
and
15 deletions.
There are no files selected for viewing
21 changes: 21 additions & 0 deletions
21
patches/net/minecraft/world/entity/npc/VillagerType.java.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
--- a/net/minecraft/world/entity/npc/VillagerType.java | ||
+++ b/net/minecraft/world/entity/npc/VillagerType.java | ||
@@ -21,6 +_,8 @@ | ||
public static final VillagerType SWAMP = register("swamp"); | ||
public static final VillagerType TAIGA = register("taiga"); | ||
private final String name; | ||
+ /** Neo: use the {@link net.neoforged.neoforge.registries.datamaps.builtin.NeoForgeDataMaps#VILLAGER_TYPES data map} instead as this field will be ignored in future versions */ | ||
+ @Deprecated | ||
private static final Map<ResourceKey<Biome>, VillagerType> BY_BIOME = Util.make(Maps.newHashMap(), p_35834_ -> { | ||
p_35834_.put(Biomes.BADLANDS, DESERT); | ||
p_35834_.put(Biomes.DESERT, DESERT); | ||
@@ -67,6 +_,9 @@ | ||
} | ||
|
||
public static VillagerType byBiome(Holder<Biome> p_204074_) { | ||
+ 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); | ||
} | ||
} |
91 changes: 91 additions & 0 deletions
91
src/generated/resources/data/neoforge/data_maps/worldgen/biome/villager_types.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
{ | ||
"values": { | ||
"minecraft:badlands": { | ||
"villager_type": "minecraft:desert" | ||
}, | ||
"minecraft:bamboo_jungle": { | ||
"villager_type": "minecraft:jungle" | ||
}, | ||
"minecraft:deep_frozen_ocean": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:desert": { | ||
"villager_type": "minecraft:desert" | ||
}, | ||
"minecraft:eroded_badlands": { | ||
"villager_type": "minecraft:desert" | ||
}, | ||
"minecraft:frozen_ocean": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:frozen_peaks": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:frozen_river": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:grove": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:ice_spikes": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:jagged_peaks": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:jungle": { | ||
"villager_type": "minecraft:jungle" | ||
}, | ||
"minecraft:mangrove_swamp": { | ||
"villager_type": "minecraft:swamp" | ||
}, | ||
"minecraft:old_growth_pine_taiga": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:old_growth_spruce_taiga": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:savanna": { | ||
"villager_type": "minecraft:savanna" | ||
}, | ||
"minecraft:savanna_plateau": { | ||
"villager_type": "minecraft:savanna" | ||
}, | ||
"minecraft:snowy_beach": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:snowy_plains": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:snowy_slopes": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:snowy_taiga": { | ||
"villager_type": "minecraft:snow" | ||
}, | ||
"minecraft:sparse_jungle": { | ||
"villager_type": "minecraft:jungle" | ||
}, | ||
"minecraft:swamp": { | ||
"villager_type": "minecraft:swamp" | ||
}, | ||
"minecraft:taiga": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:windswept_forest": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:windswept_gravelly_hills": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:windswept_hills": { | ||
"villager_type": "minecraft:taiga" | ||
}, | ||
"minecraft:windswept_savanna": { | ||
"villager_type": "minecraft:savanna" | ||
}, | ||
"minecraft:wooded_badlands": { | ||
"villager_type": "minecraft:desert" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
src/main/java/net/neoforged/neoforge/registries/datamaps/builtin/BiomeVillagerType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (c) NeoForged and contributors | ||
* SPDX-License-Identifier: LGPL-2.1-only | ||
*/ | ||
|
||
package net.neoforged.neoforge.registries.datamaps.builtin; | ||
|
||
import com.mojang.serialization.Codec; | ||
import com.mojang.serialization.codecs.RecordCodecBuilder; | ||
import net.minecraft.core.registries.BuiltInRegistries; | ||
import net.minecraft.world.entity.npc.VillagerType; | ||
|
||
/** | ||
* Data map value for {@linkplain NeoForgeDataMaps#VILLAGER_TYPES biome villager types}. | ||
* | ||
* @param type the type of the villagers present in this biome | ||
*/ | ||
public record BiomeVillagerType(VillagerType type) { | ||
public static final Codec<BiomeVillagerType> TYPE_CODEC = BuiltInRegistries.VILLAGER_TYPE.byNameCodec() | ||
.xmap(BiomeVillagerType::new, BiomeVillagerType::type); | ||
public static final Codec<BiomeVillagerType> CODEC = Codec.withAlternative( | ||
RecordCodecBuilder.create(in -> in.group( | ||
BuiltInRegistries.VILLAGER_TYPE.byNameCodec().fieldOf("villager_type").forGetter(BiomeVillagerType::type)).apply(in, BiomeVillagerType::new)), | ||
TYPE_CODEC); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters