Skip to content

Commit 327c197

Browse files
authored
Keep old expansion machine data when upgrading worlds on 1.21.1
Keep old expansion machine data when upgrading worlds on 1.21.1
2 parents c07f6f3 + b42b92b commit 327c197

15 files changed

Lines changed: 718 additions & 58 deletions

File tree

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ jobs:
7171
--no-daemon --stacktrace
7272
first="$RUNNER_TEMP/basemetals-first"
7373
mkdir -p "$first"
74-
cp build/libs/BaseMetals-3.1.1.121011.jar "$first/"
75-
cp build/libs/BaseMetals-3.1.1.121011-sources.jar "$first/"
76-
cp build/libs/BaseMetals-3.1.1.121011-javadoc.jar "$first/"
74+
cp build/libs/BaseMetals-3.1.2.121011.jar "$first/"
75+
cp build/libs/BaseMetals-3.1.2.121011-sources.jar "$first/"
76+
cp build/libs/BaseMetals-3.1.2.121011-javadoc.jar "$first/"
7777
cp build/release/SHA256SUMS "$first/"
7878
7979
- name: Rebuild and prove byte-identical archives
8080
run: |
8181
./gradlew clean assemble verifyReleaseArtifacts writeReleaseChecksums \
8282
-PorespawnVerificationRepository="${{ steps.orespawn.outputs.repository }}" \
8383
--no-daemon --stacktrace
84-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.121011.jar" build/libs/BaseMetals-3.1.1.121011.jar
85-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.121011-sources.jar" build/libs/BaseMetals-3.1.1.121011-sources.jar
86-
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.1.121011-javadoc.jar" build/libs/BaseMetals-3.1.1.121011-javadoc.jar
84+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.121011.jar" build/libs/BaseMetals-3.1.2.121011.jar
85+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.121011-sources.jar" build/libs/BaseMetals-3.1.2.121011-sources.jar
86+
cmp "$RUNNER_TEMP/basemetals-first/BaseMetals-3.1.2.121011-javadoc.jar" build/libs/BaseMetals-3.1.2.121011-javadoc.jar
8787
cmp "$RUNNER_TEMP/basemetals-first/SHA256SUMS" build/release/SHA256SUMS
8888
8989
- name: Run all required GameTests
@@ -151,9 +151,9 @@ jobs:
151151
if-no-files-found: error
152152
retention-days: 30
153153
path: |
154-
build/libs/BaseMetals-3.1.1.121011.jar
155-
build/libs/BaseMetals-3.1.1.121011-sources.jar
156-
build/libs/BaseMetals-3.1.1.121011-javadoc.jar
154+
build/libs/BaseMetals-3.1.2.121011.jar
155+
build/libs/BaseMetals-3.1.2.121011-sources.jar
156+
build/libs/BaseMetals-3.1.2.121011-javadoc.jar
157157
build/release/SHA256SUMS
158158
CHANGELOG.txt
159159

‎CHANGELOG.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
Base Metals 3.1.2.121011
2+
3+
- Keep machine directions, inventories and item wear when upgrading an old world with the Base Metals expansions installed.
4+
15
Base Metals 3.1.1.121011
26

37
- Fix startup failures when Base Metals is added to an existing modern world, including worlds with LZ4-compressed chunks, external chunks or empty region files.

‎README.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ 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 1.21.1 Forge version, `3.1.1.121011`. It keeps the
15+
This is the Minecraft 1.21.1 Forge version, `3.1.2.121011`. It keeps the
1616
fixes and features from the released 1.20.6 version, including raw metals, ore texture
1717
overlays and High/Low Fantasy modes. Existing Base Metals items and blocks keep
1818
their registry IDs. OreSpawn handles ore generation; MMDLib and Additional Loot
@@ -26,7 +26,7 @@ Tables are no longer needed.
2626
- OreSpawn `[4.1.0.121011,5.0.0)` on both client and server
2727

2828
This version uses OreSpawn `4.1.0.121011`. Put
29-
`BaseMetals-3.1.1.121011.jar` and a compatible OreSpawn JAR in the `mods`
29+
`BaseMetals-3.1.2.121011.jar` and a compatible OreSpawn JAR in the `mods`
3030
directory. MMDLib and Additional Loot Tables must not be carried forward from
3131
an older installation. Mineralogy is optional.
3232

@@ -199,7 +199,7 @@ early splash window. Minecraft still opens its game window and runs the full
199199
world check. Ordinary client launches keep the normal splash screen.
200200

201201
Release artifacts use Maven coordinate
202-
`zone.moddev.mc.basemetals:BaseMetals:3.1.1.121011`.
202+
`zone.moddev.mc.basemetals:BaseMetals:3.1.2.121011`.
203203

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

‎docs/MIGRATION.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@ Base Metals 2.5 line. Registry paths containing uppercase characters, which
3939
Minecraft 1.10 still allowed, are normalized to the lowercase form required by
4040
modern Minecraft.
4141

42+
Updated companion mods can supply their own metadata decoder and legacy
43+
data conversions through `Legacy112MigrationExtension`. When a companion
44+
claims a block, its saved state is restored instead of using the block's
45+
default. The extension can also preserve item data before Minecraft turns
46+
it into components. Companions without a decoder keep the default-state
47+
behavior described above.
48+
4249
Base Metals 3.1.0 preserves historical `basemetals:*` IDs, including hidden
4350
`double_<material>_slab` blocks and molten-fluid block IDs such as
4451
`basemetals:adamantine`. Dedicated bucket items and flowing-fluid registry

‎docs/VERSIONS.md‎

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

3-
Base Metals `3.1.1.121011` targets Minecraft 1.21.1, Forge 52.1.0 and Java 21.
3+
Base Metals `3.1.2.121011` targets Minecraft 1.21.1, Forge 52.1.0 and Java 21.
44
OreSpawn `4.1.0.121011` is the exact build and test dependency. Clients and
55
servers need OreSpawn `[4.1.0.121011,5.0.0)`.
66

@@ -10,7 +10,7 @@ Its SHA-256 is
1010
`EB369B7D7CE6D6C453658347A420C2F0783B7F4D1AC7383C87176AC05192B5A0`.
1111

1212
Release artifacts use Maven coordinate
13-
`zone.moddev.mc.basemetals:BaseMetals:3.1.1.121011`.
13+
`zone.moddev.mc.basemetals:BaseMetals:3.1.2.121011`.
1414

1515
The provider remains schema 3, revision 1. OreSpawn 4.1 is needed for the
1616
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.121011
70+
mod_version=3.1.2.121011
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
@@ -317,7 +317,7 @@ def verifyEclipseProductionClasspath = tasks.register('verifyEclipseProductionCl
317317
}
318318
}
319319
String metadata = new File(projectDir, 'bin/main/META-INF/mods.toml').getText('UTF-8')
320-
if (metadata.contains('${') || !metadata.contains('version="3.1.1.121011"')) {
320+
if (metadata.contains('${') || !metadata.contains('version="3.1.2.121011"')) {
321321
throw new GradleException('Eclipse output contains unresolved or invalid Base Metals version metadata')
322322
}
323323
}

‎gradle/release/artifacts.gradle‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ tasks.register('verifyReleaseConfiguration') {
201201
dependsOn tasks.named('verifyMavenizerCompatibilityFixture')
202202
dependsOn tasks.named('verifyJava21Toolchain')
203203
doLast {
204-
if (configuredReleaseIdentity.modVersion != '3.1.1.121011'
204+
if (configuredReleaseIdentity.modVersion != '3.1.2.121011'
205205
|| configuredReleaseIdentity.modGroup != expectedMavenGroup
206206
|| configuredReleaseIdentity.minecraftVersion != '1.21.1'
207207
|| configuredReleaseIdentity.forgeVersion != '52.1.0'
@@ -320,7 +320,7 @@ tasks.register('verifyReleaseArtifacts') {
320320
}
321321
String modsToml = zip.getInputStream(zip.getEntry('META-INF/mods.toml')).getText('UTF-8')
322322
if (modsToml.contains('${')
323-
|| !modsToml.contains('version="3.1.1.121011"')
323+
|| !modsToml.contains('version="3.1.2.121011"')
324324
|| !modsToml.contains('versionRange="[4.1.0.121011,5.0.0)"')) {
325325
throw new GradleException('Release mods.toml contains unresolved or incompatible metadata')
326326
}

‎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.121011'
177+
if (values.getProperty('basemetals') != '3.1.2.121011'
178178
|| values.getProperty('orespawn') != '4.1.0.121011'
179179
|| values.getProperty('forge') != '52.1.0') {
180180
throw new GradleException("Packaged dedicated-server versions are wrong: ${values}")
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package zone.moddev.mc.basemetals.api.migration;
2+
3+
import net.minecraft.nbt.CompoundTag;
4+
import net.minecraft.resources.ResourceLocation;
5+
import net.minecraft.world.level.block.state.BlockState;
6+
import zone.moddev.mc.basemetals.migration.Legacy112WorldMigrator;
7+
8+
/**
9+
* Lets a companion mod preserve its data when Base Metals pre-flattens a
10+
* Minecraft 1.10 or 1.12 world. Register during common setup, before worlds load.
11+
*/
12+
public interface Legacy112MigrationExtension {
13+
enum Payload { CHUNK, PLAYER }
14+
15+
/**
16+
* Updates a legacy chunk or player payload in place, before vanilla's data
17+
* fixer or the migrator's block entity snapshot. Leave stacks that vanilla
18+
* recognizes in the legacy item format so its fixer can componentize them.
19+
* Return true on mutation.
20+
*/
21+
default boolean prepareData(CompoundTag tag, int dataVersion, Payload payload) { return false; }
22+
23+
/** Runs immediately before the intermediate chunk data fix, only for chunks being converted. */
24+
default void beforeChunkFlattening(CompoundTag chunk) { }
25+
26+
/**
27+
* Checks or restores extension data after vanilla flattens the embedded
28+
* single-player record to the 1.20.1 schema (data version 3465). The prepared
29+
* source is a read-only legacy snapshot; the mutable result still stores
30+
* items as {@code Count} and {@code tag}. Base Metals runs the remaining native data fixes,
31+
* including item component conversion, after all callbacks return. Vanilla
32+
* does not componentize arbitrary stacks inside opaque mod payloads.
33+
*/
34+
default void afterPlayerFlattening(CompoundTag preparedSource, CompoundTag result) { }
35+
36+
/**
37+
* Returns the native state for an owned legacy block, or null for an ID
38+
* this extension does not own. Metadata is the original four-bit value.
39+
*/
40+
default BlockState decodeBlockState(ResourceLocation legacyId, int metadata) { return null; }
41+
42+
/** The ID identifies the registering extension and must be unique. */
43+
static void register(ResourceLocation id, Legacy112MigrationExtension extension) {
44+
Legacy112WorldMigrator.registerExtension(id, extension);
45+
}
46+
}

0 commit comments

Comments
 (0)