{"record":{"id":"3dd27140bfe2805f","repo":"Pumpkin-MC/Pumpkin","slug":"invalid-field-type-for-0","errorCode":null,"errorMessage":"Invalid field type for {0}","messagePattern":"Invalid field type for (.+?)","errorType":"error_code","errorClass":"TemplateError","httpStatus":null,"severity":"error","filePath":"crates/pumpkin-world/src/generation/structure/template/structure_template.rs","lineNumber":25,"sourceCode":"\nuse pumpkin_data::{Mirror, Rotation};\nuse pumpkin_nbt::{compound::NbtCompound, nbt_compress::read_gzip_compound_tag, tag::NbtTag};\nuse pumpkin_util::math::{block_box::BlockBox, vector3::Vector3};\nuse thiserror::Error;\n\nuse super::processor::StructureProcessor;\nuse crate::generation::structure::structures::jigsaw::JigsawJointType;\n\n/// Errors that can occur when loading or saving a structure template.\n#[derive(Debug, Error)]\npub enum TemplateError {\n    #[error(\"Failed to decompress NBT: {0}\")]\n    NbtError(#[from] pumpkin_nbt::Error),\n\n    #[error(\"Missing required field: {0}\")]\n    MissingField(&'static str),\n\n    #[error(\"Invalid field type for {0}\")]\n    InvalidFieldType(&'static str),\n\n    #[error(\"Invalid palette index: {0}\")]\n    InvalidPaletteIndex(u32),\n}\n\n/// Settings used when placing, transforming, or querying a [`StructureTemplate`].\n#[derive(Clone, Debug)]\npub struct StructurePlaceSettings {\n    pub mirror: Mirror,\n    pub rotation: Rotation,\n    pub rotation_pivot: Vector3<i32>,\n    pub bounding_box: Option<BlockBox>,\n    pub ignore_entities: bool,\n    pub apply_waterlogging: bool,\n    pub known_shape: bool,\n    pub processors: Vec<StructureProcessor>,\n    pub finalize_entities: bool,","sourceCodeStart":7,"sourceCodeEnd":43,"githubUrl":"https://github.com/Pumpkin-MC/Pumpkin/blob/8d4639e25a57c15e47448ec327c780d41bbf2356/crates/pumpkin-world/src/generation/structure/template/structure_template.rs#L7-L43","documentation":"TemplateError::InvalidFieldType is raised by StructureTemplate::load and load_palette when an NBT field inside a structure template exists but has the wrong tag type or shape. The error names the offending field (e.g. 'palette', 'entities.pos', 'blocks.pos'), so the template NBT does not match the vanilla structure-template schema. It is thrown while parsing a structure template NBT compound, meaning the template file itself is malformed.","triggerScenarios":"StructureTemplate::load encounters: a 'palette' entry that is not a List-of-Lists; a palette or entities/blocks entry that is not a Compound; entities.pos or blocks.pos lists whose length != 3; pos elements that cannot be extracted as doubles/ints. Any of these call sites (structure_template.rs:908-1004) produce this error.","commonSituations":"Hand-edited or programmatically generated .nbt structure files with wrong tag types; templates exported by modified or older Minecraft versions with a different schema; corruption from incorrect NBT serialization in custom tooling; truncation or wrong compression leaving garbage tags.","solutions":["Regenerate the structure template by exporting it again from a vanilla Minecraft world (place the structure and use a structure block to save it).","Validate the template NBT shape before loading: check that 'palette' is a List of Lists of Compounds and that 'entities.pos'/'blocks.pos' are lists of exactly 3 numeric tags.","If building NBT programmatically, fix the writer to emit the correct tag types (Int for state/pos ints, Double for entity pos, Compound per entry).","Inspect the field named in the error message with an NBT viewer (e.g. NBTExplorer) to confirm the tag type."],"exampleFix":"// before: palette stored as a flat list of compounds\ncompound.put_list(\"palette\", flat_palette_tags);\n// after: palettes is a list of palettes (list of lists of compounds)\ncompound.put_list(\"palettes\", NbtTag::List(vec![NbtTag::List(palette_entries)]));","handlingStrategy":"validation","validationCode":"fn template_nbt_shape_ok(nbt: &NbtCompound) -> bool {\n    let palettes_ok = match nbt.get_list(\"palettes\") {\n        Some(p) => p.iter().all(|t| matches!(t, NbtTag::List(_))),\n        None => matches!(nbt.get_list(\"palette\"), Some(_)),\n    };\n    let entities_ok = nbt.get_list(\"entities\").map(|e| e.iter().all(|t| matches!(t, NbtTag::Compound(_)))).unwrap_or(true);\n    palettes_ok && entities_ok\n}","typeGuard":"fn as_list(tag: &NbtTag) -> Option<&Vec<NbtTag>> {\n    if let NbtTag::List(l) = tag { Some(l) } else { None }\n}","tryCatchPattern":"match template.load(&compound) {\n    Err(TemplateError::InvalidFieldType(field)) => eprintln!(\"malformed template NBT at field '{field}'\"),\n    Err(e) => return Err(e),\n    Ok(()) => {}\n}","preventionTips":["Always export templates with vanilla structure blocks, never hand-edit .nbt files","Validate pos lists are length 3 before saving templates from custom tools","Round-trip test: save a template, load it, compare sizes","Use an NBT viewer to verify tag types after any custom serialization"],"tags":["nbt","structure-template","parsing","deserialization"],"backgroundTag":"schema-validation-failed","analyzedSha":"8d4639e25a57c15e47448ec327c780d41bbf2356","analyzedAt":"2026-09-09T15:32:22.916Z","contentChangedAt":"2026-09-09T15:32:22.916Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}