Loot patches
Select and edit loot tables at server reload.
Loot patches modify selected tables after ordinary mod modifications. A patch can replace a whole table, edit item entries or append pools and functions; it adds no table traversal to individual loot rolls.
Where the files live
Use data/<namespace>/loot_patches/<path>.json. The namespace and path identify the patch. Higher-priority resource packs replace the same file; that ID also overrides a bundled code patch. Different patches run by ascending numeric priority, then full ID. Operations within one patch run in array order.
The bundled policies are isekaiexpansion:loot/foreign_nbt and isekaiexpansion:loot/pack_rewards. Override either with a disabled file to turn that policy off.
Three catalogue table patches also ship: isekaiexpansion:loot/chest_pickups/common, isekaiexpansion:loot/chest_pickups/uncommon and isekaiexpansion:loot/chest_pickups/rare, at priority 20. They populate the corresponding isekaiexpansion:chest_pickups/common, isekaiexpansion:chest_pickups/uncommon and isekaiexpansion:chest_pickups/rare tables. Ordinary chest tables receive 3 independent bonus rolls: equipment, gem-like materials and miscellaneous pickups. Each adds at most 1 item, so equipment can appear alongside a gem or smithing stone and a Veilglass Seal. Each pool has total weight 10025. Equipment weights are 300 common, 140 uncommon and 50 rare; gem-like weights are 600 Fusible Gem, 450 Smithing Stone Shard, 125 Smithing Stone and 35 Smithing Stone Chunk; the seal has weight 25. Empty weights are 9535, 8815 and 10000 respectively.
Minimal example
data/isekaiexpansion/loot_patches/example_disabled.json ships as a harmless example:
{ "enabled": false }
Fields
| Field | Type | Default | Meaning |
|---|---|---|---|
enabled | boolean | true | false disables this ID, including a bundled policy with that ID. |
priority | integer | 0 | Signed ordering value; lower runs first. |
sources | array of strings | All | VANILLA, MOD, DATA_PACK or REPLACED. Empty selects nothing. |
tables | array of identifiers | All | Exact table IDs; empty selects nothing. |
namespaces | array of strings | All | Exact namespaces; empty selects nothing. |
path_prefix | string | Any | Case-sensitive prefix of the table path. |
exclude_namespaces | array of strings | Empty | Namespaces excluded after positive selection. |
operations | array of objects | Required when enabled | Applied in order; empty performs no edits. |
operations[].type | string | Required | One of the operation names below. |
operations[].from | identifier | Required for replace_item | Item entry to match. |
operations[].to | identifier | Required for replace_item | New item entry ID; retains weight, quality, conditions and functions. |
operations[].items | array of identifiers | Required for remove_items | Remove these entries recursively and prune empty composites. |
operations[].pool | loot-pool object | Required for add_pool | Append a vanilla-format pool. |
operations[].function | loot-function object | Required for append_function and entry_function | Append to the table or matched item entries. |
operations[].item | identifier | Required for entry_function | Item whose entries receive the function. |
operations[].table | loot-table object | Required for replace_table | Replace pools, functions, context type and random sequence together. |
clear_pools accepts only type; existing table functions remain. Selector categories intersect; values within an array are alternatives. Duplicate selector strings are rejected.
Two functions are also available in ordinary loot JSON. Their common function field is isekaiexpansion:replace_item or isekaiexpansion:strip_nbt; optional conditions uses the normal loot-condition array.
| Field | Type | Default | Meaning |
|---|---|---|---|
function | identifier | Required | Registered loot-function ID. |
conditions | array of loot conditions | Empty | Conditions checked before executing the function. |
from | item identifier | Required for replacement | Only this generated item is substituted. |
targets | array of objects | Required, nonempty | Weighted replacement choices; does not alter pool selection probability. |
targets[].item | item identifier | Required | Registered target; minecraft:air removes the result. |
targets[].weight | integer | 1 | Positive relative weight; total must fit a signed integer. |
targets[].min | integer | -1 | -1 preserves the generated count; otherwise 0–2304. |
targets[].max | integer | Same as min | At least min, at most 2304; both must be -1 to preserve count. |
chance | number | 1 | Finite probability 0–1, for either function. |
copy_nbt | boolean | false | Replacement copies the old stack’s NBT when enabled. |
default | rule object | Clear all | Default NBT removal rule. |
default.clear_all | boolean | true | Remove all NBT; ignores strip patterns. |
default.strip_keys | array of regex strings | Empty | Full-match top-level key patterns, used when clear_all is false. |
overrides | array of objects | Empty | Item-specific NBT rules; later duplicate item wins. |
overrides[].item | item identifier | Required | Registered item for this rule. |
overrides[].rule | rule object | Default rule | Replacement rule for this item. |
overrides[].rule.clear_all | boolean | Inherited from default | Whether to clear all NBT. |
overrides[].rule.strip_keys | array of regex strings | Empty | Full-match top-level patterns when not clearing all. |
Validation
Unknown patch/operation keys, missing required fields, malformed IDs, duplicate selectors and unknown operation/source names fail reload. A disabled file skips operation parsing. Pool, table and function objects use the normal loot deserializer; the complete patched table is deserialized before replacing its live builder. Replacement-function items and NBT-override items must exist; invalid probabilities, count ranges or regex patterns reject those functions. Extra keys inside the two custom function objects are ignored by their serializers.
Reloading
Server startup and /reload rebuild the patch snapshot. Patches do not sync to clients. Runtime rolls execute the resulting loot table and functions; selection and recursive editing happen during reload.