Skip to content

Commit 33429bb

Browse files
committed
Port OreSpawn to NeoForge 1.21.1
1 parent 52e2a44 commit 33429bb

44 files changed

Lines changed: 137 additions & 131 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# MMD OreSpawn
22

3-
OreSpawn 4 is a provider-driven world-generation engine for Minecraft 1.20.6.
3+
OreSpawn 4 is a provider-driven world-generation engine for Minecraft 1.21.1.
44
It gives mods and modpacks one place to configure ores, deposit shapes, optional
55
rock strata and geomes, provider-owned underground fluid deposits, biome
66
palettes and world materials, flat bedrock, and bounded ore retrogen.

docs/API.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ Submit declarations during `InterModEnqueueEvent`:
2121

2222
```java
2323
WorldgenProvider provider = WorldgenProvider.builder("examplemod", 1)
24-
.rock(new ResourceLocation("examplemod", "slate"), GeologyFamily.METAMORPHIC, rock -> rock
24+
.rock(ResourceLocation.fromNamespaceAndPath("examplemod", "slate"), GeologyFamily.METAMORPHIC, rock -> rock
2525
.depth(12, 36)
2626
.weight(1.2)
2727
.oreReplaceable(true))
@@ -56,17 +56,17 @@ FormationDefinition formations = FormationDefinition.builder()
5656
.waviness(FormationPreset.LARGE)
5757
.build();
5858
FluidDepositDefinition brine = FluidDepositDefinition.builder(
59-
new ResourceLocation("examplemod", "fluid_deposit/brine"),
60-
new ResourceLocation("examplemod", "brine"))
61-
.dimension(new ResourceLocation("minecraft", "overworld"), placement -> placement
59+
ResourceLocation.fromNamespaceAndPath("examplemod", "fluid_deposit/brine"),
60+
ResourceLocation.fromNamespaceAndPath("examplemod", "brine"))
61+
.dimension(ResourceLocation.fromNamespaceAndPath("minecraft", "overworld"), placement -> placement
6262
.yRange(-48, 32)
6363
.attempts(0.05)
6464
.radius(4, 10)
6565
.verticalRadius(2, 4)
6666
.maxLobes(3)
6767
.minSolidCover(2)
6868
.minSolidShell(1)
69-
.hostTag(new ResourceLocation("minecraft", "stone_ore_replaceables")))
69+
.hostTag(ResourceLocation.fromNamespaceAndPath("minecraft", "stone_ore_replaceables")))
7070
.build();
7171

7272
WorldgenProvider provider = WorldgenProvider.builder("examplemod", 1)
@@ -77,14 +77,14 @@ WorldgenProvider provider = WorldgenProvider.builder("examplemod", 1)
7777
`OilDefinition` and template `.oil(...)` remain deprecated migration adapters
7878
for one legacy oil rule. New integrations should use `FluidDepositDefinition`.
7979

80-
NeoForge 20.6 biomes are data-driven registry entries. Package biome JSON under
80+
NeoForge 21.1 biomes are data-driven registry entries. Package biome JSON under
8181
`data/<modid>/worldgen/biome/`, or generate it with a
8282
`DatapackBuiltinEntriesProvider`. `OreSpawnBiomes.copyAndRegister` is an
8383
optional bootstrap/datagen convenience for cloning a known biome:
8484

8585
```java
8686
public static final ResourceKey<Biome> CANDY_PLAINS = ResourceKey.create(
87-
Registries.BIOME, new ResourceLocation("examplemod", "candy_plains"));
87+
Registries.BIOME, ResourceLocation.fromNamespaceAndPath("examplemod", "candy_plains"));
8888

8989
public static final RegistrySetBuilder BIOME_BUILDER = new RegistrySetBuilder()
9090
.add(Registries.BIOME, context -> {
@@ -99,21 +99,21 @@ materials through the same OreSpawn provider:
9999

100100
```java
101101
WorldgenProvider provider = WorldgenProvider.builder("examplemod", 1)
102-
.biomePalette(new ResourceLocation("examplemod", "overworld"),
103-
new ResourceLocation("minecraft", "overworld"), palette -> palette
102+
.biomePalette(ResourceLocation.fromNamespaceAndPath("examplemod", "overworld"),
103+
ResourceLocation.fromNamespaceAndPath("minecraft", "overworld"), palette -> palette
104104
.mode(BiomePlacementMode.REPLACE)
105105
.scope(BiomeReplacementScope.MINECRAFT_ONLY)
106106
.regionSize(BiomeRegionSize.LARGE)
107107
.coverage(1.0)
108108
.fallbackWeight(0.0)
109-
.biome(new ResourceLocation("examplemod", "candy_plains"), biome -> biome
109+
.biome(ResourceLocation.fromNamespaceAndPath("examplemod", "candy_plains"), biome -> biome
110110
.weight(3.0)
111-
.similarBiome(new ResourceLocation("minecraft", "plains"))))
112-
.dimensionMaterials(new ResourceLocation("examplemod", "overworld_materials"),
113-
new ResourceLocation("minecraft", "overworld"), materials -> materials
114-
.defaultFluid(new ResourceLocation("examplemod", "lemonade"))
115-
.snowBlock(new ResourceLocation("examplemod", "icing"))
116-
.iceBlock(new ResourceLocation("examplemod", "frozen_lemonade")))
111+
.similarBiome(ResourceLocation.fromNamespaceAndPath("minecraft", "plains"))))
112+
.dimensionMaterials(ResourceLocation.fromNamespaceAndPath("examplemod", "overworld_materials"),
113+
ResourceLocation.fromNamespaceAndPath("minecraft", "overworld"), materials -> materials
114+
.defaultFluid(ResourceLocation.fromNamespaceAndPath("examplemod", "lemonade"))
115+
.snowBlock(ResourceLocation.fromNamespaceAndPath("examplemod", "icing"))
116+
.iceBlock(ResourceLocation.fromNamespaceAndPath("examplemod", "frozen_lemonade")))
117117
.build();
118118
```
119119

docs/BIOMES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ known biome's complete builder inside a `RegistrySetBuilder` bootstrap:
100100

101101
```java
102102
public static final ResourceKey<Biome> CANDY_PLAINS = ResourceKey.create(
103-
Registries.BIOME, new ResourceLocation("examplemod", "candy_plains"));
103+
Registries.BIOME, ResourceLocation.fromNamespaceAndPath("examplemod", "candy_plains"));
104104

105105
public static final RegistrySetBuilder BIOME_BUILDER = new RegistrySetBuilder()
106106
.add(Registries.BIOME, context -> {
@@ -114,7 +114,7 @@ public static final RegistrySetBuilder BIOME_BUILDER = new RegistrySetBuilder()
114114
datagen that deliberately supplies every required climate, effects, spawn, and
115115
generation field. Both helpers create datapack content; live placement belongs
116116
in the provider declaration. Do not use a static `DeferredRegister<Biome>`:
117-
NeoForge 20.6 biomes belong to the dynamic world registry.
117+
NeoForge 21.1 biomes belong to the dynamic world registry.
118118

119119
## Surfaces And Materials
120120

docs/DEVELOPER_GUIDE.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ import net.minecraft.resources.ResourceLocation;
8989
import net.neoforged.fml.event.lifecycle.InterModEnqueueEvent;
9090

9191
private void enqueueWorldgen(InterModEnqueueEvent event) {
92-
ResourceLocation tin = new ResourceLocation("examplemod", "tin_ore");
92+
ResourceLocation tin = ResourceLocation.fromNamespaceAndPath("examplemod", "tin_ore");
9393
WorldgenProvider provider = WorldgenProvider.builder("examplemod", 1)
9494
.ore(tin, ore -> ore
9595
.retrogen(false)
@@ -100,7 +100,7 @@ private void enqueueWorldgen(InterModEnqueueEvent event) {
100100
.quantityRange(4, 11)
101101
.pattern(OrePattern.VEIN)
102102
.heightDistribution(OreHeightDistribution.TRIANGLE)
103-
.hostTag(new ResourceLocation("minecraft", "stone_ore_replaceables"))))
103+
.hostTag(ResourceLocation.fromNamespaceAndPath("minecraft", "stone_ore_replaceables"))))
104104
.build();
105105

106106
OreSpawnApi.enqueue(provider);

gradle.properties

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@ org.gradle.configuration-cache=false
1010
## Environment Properties
1111

1212
# The Minecraft version must agree with the NeoForge version to get a valid artifact
13-
minecraft_version=1.20.6
13+
minecraft_version=1.21.1
1414
# The Minecraft version range can use any release version of Minecraft as bounds.
1515
# Snapshots, pre-releases, and release candidates are not guaranteed to sort properly
1616
# as they do not follow standard versioning conventions.
17-
minecraft_version_range=[1.20.6,1.21)
18-
# NeoForge 20.6 targets Minecraft 1.20.6.
19-
neo_version=20.6.139
20-
neo_version_range=[20.6.139,20.7)
21-
# NeoForge 20.6 uses FML loader major 2.
22-
loader_version_range=[2,)
17+
minecraft_version_range=[1.21.1,1.22)
18+
# NeoForge 21.1 targets Minecraft 1.21.1.
19+
neo_version=21.1.247
20+
neo_version_range=[21.1.247,21.2)
21+
# NeoForge 21.1.247 declares JavaFML loader major 3.
22+
loader_version_range=[3,)
2323

2424

2525
## Mod Properties

src/main/java/zone/moddev/mc/orespawn/api/GeologyProfileView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Optional<ResourceLocation> selectedTemplate() {
3131
return Optional.empty();
3232
}
3333
try {
34-
return Optional.of(new ResourceLocation(root.get("selected_template").getAsString()));
34+
return Optional.of(ResourceLocation.parse(root.get("selected_template").getAsString()));
3535
} catch (RuntimeException ignored) {
3636
return Optional.empty();
3737
}
@@ -77,7 +77,7 @@ private Set<ResourceLocation> keys(String section) {
7777
Set<ResourceLocation> values = new LinkedHashSet<>();
7878
for (String value : root.getAsJsonObject(section).keySet()) {
7979
try {
80-
values.add(new ResourceLocation(value));
80+
values.add(ResourceLocation.parse(value));
8181
} catch (RuntimeException ignored) {
8282
// Invalid user data is omitted from the typed view.
8383
}

src/main/java/zone/moddev/mc/orespawn/api/OreDimensionSelector.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ public enum OreDimensionSelector {
1111
private final ResourceLocation id;
1212

1313
OreDimensionSelector(String path) {
14-
this.id = new ResourceLocation("orespawn", path);
14+
this.id = ResourceLocation.fromNamespaceAndPath("orespawn", path);
1515
}
1616

1717
public ResourceLocation id() {
@@ -27,8 +27,8 @@ public static OreDimensionSelector fromId(ResourceLocation id) {
2727

2828
public static OreDimensionSelector fromName(String value) {
2929
ResourceLocation id = value.indexOf(':') >= 0
30-
? new ResourceLocation(value)
31-
: new ResourceLocation("orespawn", value.toLowerCase(Locale.ROOT));
30+
? ResourceLocation.parse(value)
31+
: ResourceLocation.fromNamespaceAndPath("orespawn", value.toLowerCase(Locale.ROOT));
3232
return fromId(id);
3333
}
3434
}

src/main/java/zone/moddev/mc/orespawn/api/OreSpawnBiomes.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* Small bootstrap helpers for provider mods which define data-driven biomes
1414
* without taking a compile-time dependency on a separate biome framework.
1515
*
16-
* <p>Biomes are dynamic registry entries in NeoForge 20.6. A provider should
16+
* <p>Biomes are dynamic registry entries in NeoForge 21.1. A provider should
1717
* package biome JSON or use these methods from a
1818
* {@link net.minecraft.core.RegistrySetBuilder} bootstrap used by datagen.
1919
*/

src/main/java/zone/moddev/mc/orespawn/api/OreSpawnGeologySampler.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
import net.minecraft.server.level.ServerLevel;
2323

2424
final class OreSpawnGeologySampler implements GeologySampler {
25-
private static final ResourceLocation CYANO_GEOME = new ResourceLocation("orespawn", "cyano");
25+
private static final ResourceLocation CYANO_GEOME = ResourceLocation.fromNamespaceAndPath("orespawn", "cyano");
2626

2727
private final ServerLevel level;
2828
private final ResourceLocation dimension;
@@ -59,7 +59,7 @@ public GeologyColumn sampleColumn(int blockX, int blockZ, int surfaceY) {
5959
BlockPos position = new BlockPos(blockX, surfaceY, blockZ);
6060
Holder<Biome> holder = level.getBiome(position);
6161
ResourceLocation biomeId = holder.unwrapKey().map(ResourceKey::location)
62-
.orElse(new ResourceLocation("orespawn", "unregistered_biome"));
62+
.orElse(ResourceLocation.fromNamespaceAndPath("orespawn", "unregistered_biome"));
6363
if (mode == GeologyMode.LEGACY) {
6464
return new CyanoColumn(biomeId, blockX, blockZ, surfaceY);
6565
}
@@ -127,10 +127,10 @@ private static Optional<GeologyFamily> family(RockFamily family) {
127127

128128
private static ResourceLocation geomeId(String name) {
129129
try {
130-
return name.indexOf(':') >= 0 ? new ResourceLocation(name)
131-
: new ResourceLocation("orespawn", name.toLowerCase(Locale.ROOT));
130+
return name.indexOf(':') >= 0 ? ResourceLocation.parse(name)
131+
: ResourceLocation.fromNamespaceAndPath("orespawn", name.toLowerCase(Locale.ROOT));
132132
} catch (RuntimeException ignored) {
133-
return new ResourceLocation("orespawn", "unknown");
133+
return ResourceLocation.fromNamespaceAndPath("orespawn", "unknown");
134134
}
135135
}
136136
}

src/main/java/zone/moddev/mc/orespawn/api/OreSpawnPatternRegistry.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/** Stable entry point for mods that register codec-backed ore patterns. */
1111
public final class OreSpawnPatternRegistry {
1212
public static final ResourceLocation REGISTRY_NAME =
13-
new ResourceLocation(OreSpawn.MODID, "ore_pattern_types");
13+
ResourceLocation.fromNamespaceAndPath(OreSpawn.MODID, "ore_pattern_types");
1414

1515
private OreSpawnPatternRegistry() {
1616
}

0 commit comments

Comments
 (0)