Support saves from 1.16.5 (DataVersion 2571 on): replaceitem for pre-1.17 scenes

This commit is contained in:
Ludovic Marie
2026-10-12 23:59:20 +02:00
parent 0870b5064b
commit 19896fb6f1
2 changed files with 8 additions and 4 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ use schema::{Key, Ty, key, walk};
pub const CURRENT: i32 = crate::DATA_VERSION;
/// Data saved before this DataVersion (1.17 is 2724) needs fixes that are not
/// ported (2717 and everything before).
pub const OLDEST_SUPPORTED: i32 = 2724;
pub const OLDEST_SUPPORTED: i32 = 2571;
/// `Identifier.tryParse` validity, as `NamespacedSchema.ensureNamespaced` uses it.
pub fn identifier(id: &str) -> Option<(String, String)> {
+7 -3
View File
@@ -367,10 +367,14 @@ def player_commands(e, name, version=None):
"""Give the joined bot a varied inventory and ender chest."""
out = []
stacks = items(e, version)
if version is not None and version < 2700: # `/item` arrived in 1.17
replace = lambda slot, item: f'replaceitem entity {name} {slot} {item}'
else:
replace = lambda slot, item: f'item replace entity {name} {slot} with {item}'
for i, stack in enumerate(stacks[:30]):
out.append(f'item replace entity {name} container.{i} with {give_form(e, stack)}')
out.append(f'item replace entity {name} enderchest.0 with {give_form(e, stacks[0])}')
out.append(f'item replace entity {name} armor.head with minecraft:iron_helmet')
out.append(replace(f'container.{i}', give_form(e, stack)))
out.append(replace('enderchest.0', give_form(e, stacks[0])))
out.append(replace('armor.head', 'minecraft:iron_helmet'))
out.append(f'xp set {name} 5 levels')
return out