Skip to content

Commit a68fe5a

Browse files
authored
Merge the Forge 26.2 companion migration hook
Keep companion block metadata, inventories and embedded host players when upgrading old worlds. Local and hosted checks passed with unchanged release jars.
2 parents 5a0473c + d688cec commit a68fe5a

19 files changed

Lines changed: 727 additions & 50 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,19 @@ jobs:
5959
--no-daemon --stacktrace
6060
first="$RUNNER_TEMP/basemetals-first"
6161
mkdir -p "$first"
62-
cp build/libs/BaseMetals-3.1.1.2602001.jar "$first/"
63-
cp build/libs/BaseMetals-3.1.1.2602001-sources.jar "$first/"
64-
cp build/libs/BaseMetals-3.1.1.2602001-javadoc.jar "$first/"
62+
cp build/libs/BaseMetals-3.1.2.2602001.jar "$first/"
63+
cp build/libs/BaseMetals-3.1.2.2602001-sources.jar "$first/"
64+
cp build/libs/BaseMetals-3.1.2.2602001-javadoc.jar "$first/"
6565
cp build/release/SHA256SUMS "$first/"
6666
6767
- name: Rebuild and prove byte-identical archives
6868
run: |
6969
./gradlew clean assemble verifyReleaseArtifacts writeReleaseChecksums \
7070
-PorespawnVerificationRepository="${{ steps.orespawn.outputs.repository }}" \
7171
--no-daemon --stacktrace
72-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.2602001.jar" build/libs/BaseMetals-3.1.1.2602001.jar
73-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.2602001-sources.jar" build/libs/BaseMetals-3.1.1.2602001-sources.jar
74-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.2602001-javadoc.jar" build/libs/BaseMetals-3.1.1.2602001-javadoc.jar
72+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.2602001.jar" build/libs/BaseMetals-3.1.2.2602001.jar
73+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.2602001-sources.jar" build/libs/BaseMetals-3.1.2.2602001-sources.jar
74+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.2602001-javadoc.jar" build/libs/BaseMetals-3.1.2.2602001-javadoc.jar
7575
cmp "$RUNNER_TEMP/basemetals-first/SHA256SUMS" build/release/SHA256SUMS
7676
7777
- name: Run all required GameTests
@@ -139,9 +139,9 @@ jobs:
139139
if-no-files-found: error
140140
retention-days: 30
141141
path: |
142-
build/libs/BaseMetals-3.1.1.2602001.jar
143-
build/libs/BaseMetals-3.1.1.2602001-sources.jar
144-
build/libs/BaseMetals-3.1.1.2602001-javadoc.jar
142+
build/libs/BaseMetals-3.1.2.2602001.jar
143+
build/libs/BaseMetals-3.1.2.2602001-sources.jar
144+
build/libs/BaseMetals-3.1.2.2602001-javadoc.jar
145145
build/release/SHA256SUMS
146146
CHANGELOG.txt
147147

‎CHANGELOG.txt‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
Base Metals 3.1.2.2602001
2+
3+
- Port the shared companion migration API from 26.1.2, including saved-world registry context.
4+
- Preserve companion block metadata, inventories and embedded host players before vanilla flattening.
5+
- Let companion chunk-return hooks run without cancellation; leave modern worlds and existing player files authoritative.
6+
17
Base Metals 3.1.1.2602001
28

39
- Port the released 26.1.2 version to Minecraft 26.2 and Forge 65, keeping Java 25.

‎README.md‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ shields, bows, crossbows, arrows, and bolts. The mod also includes Crack
1212
Hammers, scythes, metal anvils, the human detector, villager trades,
1313
advancements, and structure loot.
1414

15-
This is the Minecraft 26.2 Forge version, `3.1.1.2602001`. It keeps the
15+
This is the Minecraft 26.2 Forge version, `3.1.2.2602001`, with the shared
16+
companion migration hook. It keeps the
1617
fixes and features from the released 26.1.2 version, including raw metals, ore
1718
texture overlays and High/Low Fantasy modes. Existing Base Metals items and
1819
blocks keep their registry IDs. OreSpawn handles ore generation; MMDLib and
@@ -25,10 +26,11 @@ Additional Loot Tables are no longer needed.
2526
- A current Java 25 runtime
2627
- OreSpawn `[4.1.0.2602001,5.0.0)` on both client and server
2728

28-
The build uses Forge `65.1.0` and is also tested on `65.1.5`.
29+
The build uses Forge `65.1.0`; `65.1.5` remains the additional compatibility
30+
target.
2931

3032
This version uses OreSpawn `4.1.0.2602001`. Put
31-
`BaseMetals-3.1.1.2602001.jar` and a compatible OreSpawn JAR in the `mods`
33+
`BaseMetals-3.1.2.2602001.jar` and a compatible OreSpawn JAR in the `mods`
3234
directory. MMDLib and Additional Loot Tables must not be carried forward from
3335
an older installation. Mineralogy is optional.
3436

@@ -201,7 +203,7 @@ early splash window. Minecraft still opens its game window and runs the full
201203
world check. Ordinary client launches keep the normal splash screen.
202204

203205
Release artifacts use Maven coordinate
204-
`zone.moddev.mc.basemetals:BaseMetals:3.1.1.2602001`.
206+
`zone.moddev.mc.basemetals:BaseMetals:3.1.2.2602001`.
205207

206208
Report defects and compatibility problems through the
207209
[Base Metals issue tracker](https://github.com/MinecraftModDevelopmentMods/BaseMetals/issues).

‎docs/MIGRATION.md‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Migrating from Base Metals 1.10 or 1.12
22

33
Always upgrade a copy and retain the original legacy world. Install Base Metals
4-
3.1.1 and OreSpawn 4.1.0, but do not carry MMDLib, Additional Loot Tables, the
4+
3.1.2 and OreSpawn 4.1.0, but do not carry MMDLib, Additional Loot Tables, the
55
OreSpawn 3 plugin, or the old native fallback generator into the 26.2 instance.
66

77
Minecraft's data fixer cannot identify third-party numeric block IDs from
@@ -156,3 +156,30 @@ an older `level.dat` over the upgraded save.
156156
If an older single-player save has its player only in `level.dat`, Base Metals
157157
preserves a separate player file before Minecraft converts the folders. An
158158
existing player file always wins; a stale backup cannot restore an older player.
159+
160+
## Companion migration extensions
161+
162+
Companion mods can register a common-side
163+
`zone.moddev.mc.basemetals.api.migration.Legacy112MigrationExtension` with a
164+
unique `Identifier` during common setup, before a world opens. Registrations
165+
run in identifier order; duplicate identifiers fail rather than replace an owner.
166+
167+
`prepareWorld` receives an independent copy of the selected world's saved
168+
registry snapshot before conversion. It also runs for modern worlds, so a
169+
companion can clear registry IDs retained from a previously opened legacy world.
170+
171+
`prepareData` receives `Payload.CHUNK` or `Payload.PLAYER` before legacy
172+
flattening. `beforeChunkFlattening` runs before the block-entity snapshot, and
173+
`decodeBlockState` can restore owned block properties from raw metadata.
174+
Return `null` for an unowned block; air or multiple claims fail conversion.
175+
176+
When a legacy host has no existing player file, `afterPlayerFlattening`
177+
receives its prepared source and the mutable schema-3465 player, before item
178+
componentization. The resulting native player seeds a separate disk file before
179+
FileFixerUpper moves it. The legacy level retains its source schema. Detached
180+
player files receive preparation only and remain under native player-loading
181+
authority. Existing player files in either layout are never replaced by the host.
182+
183+
Chunk finalization edits the returned tag in place and does not cancel other
184+
mods' return callbacks. Extensions must preserve unowned data, register on both
185+
physical sides, and avoid client-only classes in these common callbacks.

‎docs/VERSIONS.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Supported versions
22

3-
Base Metals `3.1.1.2602001` targets Minecraft 26.2, Forge 65.1.0 and Java 25.
3+
Base Metals `3.1.2.2602001` is a local candidate for Minecraft 26.2, Forge 65.1.0
4+
and Java 25. It is not published or fully qualified yet.
45
Forge 65.1.5 is the additional compatibility target.
56
OreSpawn `4.1.0.2602001` is the exact build and test dependency. Clients and
67
servers need OreSpawn `[4.1.0.2602001,5.0.0)`.
@@ -11,7 +12,7 @@ Its SHA-256 is
1112
`F74785025898DF059E0F00F6ADA53364E07ECBBC306807ED7CD55350609E2547`.
1213

1314
Release artifacts use Maven coordinate
14-
`zone.moddev.mc.basemetals:BaseMetals:3.1.1.2602001`.
15+
`zone.moddev.mc.basemetals:BaseMetals:3.1.2.2602001` once approved and published.
1516

1617
The provider remains schema 3, revision 1. OreSpawn 4.1 is needed for the
1718
configuration-screen API; the provider's eleven rule IDs and 1.18 distributions

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ mod_name=Base Metals
6767
# The license of the mod. Review your options at https://choosealicense.com/. All Rights Reserved is the default.
6868
mod_license=LGPL-2.1
6969
# The mod version. See https://semver.org/
70-
mod_version=3.1.1.2602001
70+
mod_version=3.1.2.2602001
7171
# The group ID for the mod. It is only important when publishing as an artifact to a Maven repository.
7272
# This should match the base package used for the mod sources.
7373
# See https://maven.apache.org/guides/mini/guide-naming-conventions.html

‎gradle/ide/eclipse.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ def verifyEclipseProductionClasspath = tasks.register('verifyEclipseProductionCl
334334
}
335335
}
336336
String metadata = new File(projectDir, 'bin/main/META-INF/mods.toml').getText('UTF-8')
337-
if (metadata.contains('${') || !metadata.contains('version="3.1.1.2602001"')) {
337+
if (metadata.contains('${') || !metadata.contains('version="3.1.2.2602001"')) {
338338
throw new GradleException('Eclipse output contains unresolved or invalid Base Metals version metadata')
339339
}
340340
}

‎gradle/release/artifacts.gradle‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ tasks.register('verifyReleaseConfiguration') {
202202
dependsOn tasks.named('verifyMavenizerCompatibilityFixture')
203203
dependsOn tasks.named('verifyJava25Toolchain')
204204
doLast {
205-
if (configuredReleaseIdentity.modVersion != '3.1.1.2602001'
205+
if (configuredReleaseIdentity.modVersion != '3.1.2.2602001'
206206
|| configuredReleaseIdentity.modGroup != expectedMavenGroup
207207
|| configuredReleaseIdentity.minecraftVersion != '26.2'
208208
|| configuredReleaseIdentity.forgeVersion != '65.1.0'
@@ -332,7 +332,7 @@ tasks.register('verifyReleaseArtifacts') {
332332
}
333333
String modsToml = zip.getInputStream(zip.getEntry('META-INF/mods.toml')).getText('UTF-8')
334334
if (modsToml.contains('${')
335-
|| !modsToml.contains('version="3.1.1.2602001"')
335+
|| !modsToml.contains('version="3.1.2.2602001"')
336336
|| !modsToml.contains('versionRange="[4.1.0.2602001,5.0.0)"')) {
337337
throw new GradleException('Release mods.toml contains unresolved or incompatible metadata')
338338
}

‎gradle/verification/packaged-runtime.gradle‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ def packagedServerStartupSmoke = tasks.register('packagedServerStartupSmoke', Ex
174174
if (!marker.isFile()) throw new GradleException('Packaged dedicated-server completion marker is missing')
175175
Properties values = new Properties()
176176
marker.withInputStream { values.load(it) }
177-
if (values.getProperty('basemetals') != '3.1.1.2602001'
177+
if (values.getProperty('basemetals') != '3.1.2.2602001'
178178
|| values.getProperty('orespawn') != '4.1.0.2602001'
179179
|| values.getProperty('forge') != '65.1.0') {
180180
throw new GradleException("Packaged dedicated-server versions are wrong: ${values}")
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
package zone.moddev.mc.basemetals.api.migration;
2+
3+
import net.minecraft.nbt.CompoundTag;
4+
import net.minecraft.resources.Identifier;
5+
import net.minecraft.world.level.block.state.BlockState;
6+
import zone.moddev.mc.basemetals.migration.Legacy112WorldMigrator;
7+
8+
/** Preserves companion data before Base Metals converts a pre-flattening world. */
9+
public interface Legacy112MigrationExtension {
10+
enum Payload { CHUNK, PLAYER }
11+
12+
/**
13+
* Supplies this selected world's saved registry context before any conversion.
14+
* Each extension receives its own copy. Modern worlds are included so a
15+
* companion can clear registry IDs retained from a previous world.
16+
*/
17+
default void prepareWorld(CompoundTag levelSnapshot) { }
18+
19+
/** Mutates owned legacy data before vanilla fixes and the block-entity snapshot. */
20+
default boolean prepareData(CompoundTag tag, int dataVersion, Payload payload) { return false; }
21+
22+
/** Runs immediately before the intermediate chunk data fix. */
23+
default void beforeChunkFlattening(CompoundTag chunk) { }
24+
25+
/**
26+
* Restores owned data at the 1.20.1 item schema, before componentization.
27+
* The prepared source is read-only; result still uses historical Count/tag.
28+
* On 26.1 and later this seeds a missing host file before FileFixerUpper moves it.
29+
*/
30+
default void afterPlayerFlattening(CompoundTag preparedSource, CompoundTag result) { }
31+
32+
/** Returns a native owned state, or null for an unowned registry ID. */
33+
default BlockState decodeBlockState(Identifier legacyId, int metadata) { return null; }
34+
35+
/** Register during common setup, before any world is opened. */
36+
static void register(Identifier id, Legacy112MigrationExtension extension) {
37+
Legacy112WorldMigrator.registerExtension(id, extension);
38+
}
39+
}

0 commit comments

Comments
 (0)