I made my castle terrain replacement this way:
"core:castle" : {
"town" : {
"mapObject" : {
"filters" : {
"village_1_dirt": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_dirt": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_dirt": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]] ] ,
"village_dirt": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_dirt" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_dirt" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_dirt" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_dirt" : "allOf", "castle" ], "capitol" ] ],
"village_1": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol" : "allOf", "castle" ], "capitol" ] ],
"village_1_lava": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_lava": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_lava": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_lava": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_lava" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_lava" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_lava" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_lava" : "allOf", "castle" ], "capitol" ] ],
"village_1_rough": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_rough": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_rough": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_rough": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_rough" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_rough" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_rough" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_rough" : "allOf", "castle" ], "capitol" ] ],
"village_1_sand": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_sand": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_sand": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_sand": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_sand" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_sand" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_sand" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_sand" : "allOf", "castle" ], "capitol" ] ],
"village_1_snow": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_snow": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_snow": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_snow": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_snow" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_snow" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_snow" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_snow" : "allOf", "castle" ], "capitol" ] ],
"village_1_subterra": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_subterra": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_subterra": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_subterra": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_subterra" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_subterra" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_subterra" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_subterra" : "allOf", "castle" ], "capitol" ] ],
"village_1_swamp": "allOf","villageHall"],"noneOf", "fort" ],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_2_swamp": "allOf","villageHall"],"tavern"],"noneOf", "fort" ],"blacksmith"],"mageGuild1"],"marketplace"],"townHall"]]] ,
"village_3_swamp": "allOf","villageHall"],"tavern"],"blacksmith"],"mageGuild1"],"marketplace"],"noneOf", "fort" ],"townHall"]]] ,
"village_swamp": "allOf","villageHall"],"tavern"],"marketplace"],"mageGuild1"],"townHall"],"noneOf", "fort" ]] ],
"fort_swamp" : "allOf", "fort" ], "noneOf", "citadel" ] ] ],
"citadel_swamp" : "allOf", "citadel" ], "noneOf", "castle" ] ] ],
"castle_swamp" : "allOf", "castle" ], "noneOf", "capitol" ] ] ],
"capitol_swamp" : "allOf", "castle" ], "capitol" ] ]
},
"templates" : {
"village_1_dirt": {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtHall"},
"village_2_dirt": {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtHall"},
"village_3_dirt": {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtHall"},
"village_dirt": {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtHall"},
"fort_dirt" : {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtCastle1"},
"citadel_dirt" : {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtCastle2"},
"castle_dirt" : {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtCastle3"},
"capitol_dirt" : {"allowedTerrains":"dirt"], "animation" : "newlook_castle/CastleDirtCastle3F"},
"village_1": {"allowedTerrains":"grass"], "animation" : "build_castle/CastleGrassBuild1"},
"village_2": {"allowedTerrains":"grass"], "animation" : "build_castle/CastleGrassBuild2"},
"village_3": {"allowedTerrains":"grass"], "animation" : "build_castle/CastleGrassBuild3"},
"village": {"allowedTerrains":"grass"], "animation" : "newlook_castle/CastleGrassHall"},
"fort" : {"allowedTerrains":"grass"], "animation" : "newlook_castle/CastleGrassCastle1"},
"citadel" : {"allowedTerrains":"grass"], "animation" : "newlook_castle/CastleGrassCastle2"},
"castle" : {"allowedTerrains":"grass"], "animation" : "newlook_castle/CastleGrassCastle3"},
"capitol" : {"allowedTerrains":"grass"], "animation" : "newlook_castle/CastleGrassCastle3F"},
"village_1_lava": {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaHall"},
"village_2_lava": {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaHall"},
"village_3_lava": {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaHall"},
"village_lava": {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaHall"},
"fort_lava" : {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaCastle1"},
"citadel_lava" : {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaCastle2"},
"castle_lava" : {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaCastle3"},
"capitol_lava" : {"allowedTerrains":"lava"], "animation" : "newlook_castle/CastleLavaCastle3F"},
"village_1_rough": {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughHall"},
"village_2_rough": {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughHall"},
"village_3_rough": {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughHall"},
"village_rough": {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughHall"},
"fort_rough" : {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughCastle1"},
"citadel_rough" : {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughCastle2"},
"castle_rough" : {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughCastle3"},
"capitol_rough" : {"allowedTerrains":"rough"], "animation" : "newlook_castle/CastleRoughCastle3F"},
"village_1_sand": {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandHall"},
"village_2_sand": {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandHall"},
"village_3_sand": {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandHall"},
"village_sand": {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandHall"},
"fort_sand" : {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandCastle1"},
"citadel_sand" : {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandCastle2"},
"castle_sand" : {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandCastle3"},
"capitol_sand" : {"allowedTerrains":"sand"], "animation" : "newlook_castle/CastleSandCastle3F"},
"village_1_snow": {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowHall"},
"village_2_snow": {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowHall"},
"village_3_snow": {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowHall"},
"village_snow": {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowHall"},
"fort_snow" : {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowCastle1"},
"citadel_snow" : {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowCastle2"},
"castle_snow" : {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowCastle3"},
"capitol_snow" : {"allowedTerrains":"snow"], "animation" : "newlook_castle/CastleSnowCastle3F"},
"village_1_swamp": {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampHall"},
"village_2_swamp": {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampHall"},
"village_3_swamp": {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampHall"},
"village_swamp": {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampHall"},
"fort_swamp" : {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampCastle1"},
"citadel_swamp" : {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampCastle2"},
"castle_swamp" : {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampCastle3"},
"capitol_swamp" : {"allowedTerrains":"swamp"], "animation" : "newlook_castle/CastleSwampCastle3F"},
"village_1_subterra": {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraHall"},
"village_2_subterra": {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraHall"},
"village_3_subterra": {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraHall"},
"village_subterra": {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraHall"},
"fort_subterra" : {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraCastle1"},
"citadel_subterra" : {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraCastle2"},
"castle_subterra" : {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraCastle3"},
"capitol_subterra" : {"allowedTerrains":"subterra"], "animation" : "newlook_castle/CastleSubterraCastle3F"}
}
}
}
}
It still works.