Skip to content

Include Operation

EnderTurret edited this page Nov 5, 2024 · 3 revisions

The include patch type allows applying another patch from a different one. They were added in versions 5.1.0+1.20.4 and 3.3.0+1.20.1 of Patched.

An include patch looks like this:

{
  "op": "include", // specifies this is an include patch
  "path": "patch_name" // the name of the patch file to include, points to patches/<path>.json.patch in the same pack
}

The primary purpose of include is to simplify repetitive patches. For example, suppose you want to add this feature to every ocean biome:

// patches/add_ocean_monster_room.json.patch
{
  "op": "add",
  "path": "/features/3/-",
  "value": "fancymonsterrooms:ocean_monster_room"
}

Copy-pasting this patch eight some times would work fine, but what if you want to change the patch later? You would have to alter every single one of these patches. Using include avoids this problem by keeping all the logic in one patch:

// cold_ocean.json.patch
// deep_cold_ocean.json.patch
// deep_frozen_ocean.json.patch
// deep_lukewarm_ocean.json.patch
// deep_ocean.json.patch
// frozen_ocean.json.patch
// lukewarm_ocean.json.patch
// ocean.json.patch
{
  "op": "include",
  "path": "add_ocean_monster_room"
}

The file structure of the pack is now this:

FancyMonsterRooms
├ data
│ ├ fancymonsterrooms
│ │ └ <omitted for brevity>
│ └ minecraft
│   └ worldgen
│     └ biome
│       └ ocean.json.patch et al.
├ pack.mcmeta
└ patches
  └ add_ocean_monster_room.json.patch

Clone this wiki locally