1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
//! V2679 (1.16.5 + 93) — schematic-relevant subset of `V2679.java`.
//!
//! BLOCK_STATE structure converter for `minecraft:cauldron`: with the 1.17
//! cauldron split, a cauldron block-state with `level == "0"` (the default when
//! absent) has its now-meaningless `Properties` removed, while any non-zero
//! water level becomes a `minecraft:water_cauldron` (V2679.java:13-34).
//!
//! VERSION = MCVersions.V1_16_5 (2586) + 93 = 2679.
//!
//! Nothing non-schematic is present in this version.
use crate::nbt::NbtMap;
use super::super::registry::RegistryBuilder;
use super::super::types::MapExt;
const VERSION: i32 = 2679;
pub fn register(reg: &mut RegistryBuilder) {
reg.block_state.add_structure_converter(
VERSION,
0,
Box::new(|data: &mut NbtMap, _from, _to| {
if data.get_string("Name") != Some("minecraft:cauldron") {
return;
}
// No Properties -> nothing to do (Java returns null).
if data.get_map("Properties").is_none() {
return;
}
// getString("level", "0") -> defaults to "0" when absent.
let level = data
.get_map("Properties")
.and_then(|p| p.get_string("level"))
.unwrap_or("0")
.to_string();
if level == "0" {
data.take("Properties");
} else {
data.set_string("Name", "minecraft:water_cauldron");
}
}),
);
// Reverse (1.17 -> 1.16.5): undo the cauldron split.
//
// The forward's only id-changing branch renamed a `minecraft:cauldron`
// with a non-zero `level` to `minecraft:water_cauldron`, preserving its
// `Properties` (including `level`). The new id therefore uniquely encodes
// the old discriminator, so the inverse is exact (rule 11): rename back to
// `minecraft:cauldron` with `Properties`/`level` untouched. No loss.
//
// The forward's other branch (level == "0" -> drop `Properties`, id stays
// `minecraft:cauldron`) needs no reverse: old `minecraft:cauldron` with an
// absent `level` is exactly level 0 (the old `getString("level", "0")`
// default), so the empty-cauldron state already round-trips.
reg.block_state.add_reverse_converter_for_id(
"minecraft:water_cauldron",
VERSION,
0,
Box::new(|data: &mut NbtMap, _from, _to| {
data.set_string("Name", "minecraft:cauldron");
}),
);
}