Kzeroko KTM2

Loot patches

Select and edit loot tables at server reload.

Updated Oct 23, 2026 5 min read

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

FieldTypeDefaultMeaning
enabledbooleantruefalse disables this ID, including a bundled policy with that ID.
priorityinteger0Signed ordering value; lower runs first.
sourcesarray of stringsAllVANILLA, MOD, DATA_PACK or REPLACED. Empty selects nothing.
tablesarray of identifiersAllExact table IDs; empty selects nothing.
namespacesarray of stringsAllExact namespaces; empty selects nothing.
path_prefixstringAnyCase-sensitive prefix of the table path.
exclude_namespacesarray of stringsEmptyNamespaces excluded after positive selection.
operationsarray of objectsRequired when enabledApplied in order; empty performs no edits.
operations[].typestringRequiredOne of the operation names below.
operations[].fromidentifierRequired for replace_itemItem entry to match.
operations[].toidentifierRequired for replace_itemNew item entry ID; retains weight, quality, conditions and functions.
operations[].itemsarray of identifiersRequired for remove_itemsRemove these entries recursively and prune empty composites.
operations[].poolloot-pool objectRequired for add_poolAppend a vanilla-format pool.
operations[].functionloot-function objectRequired for append_function and entry_functionAppend to the table or matched item entries.
operations[].itemidentifierRequired for entry_functionItem whose entries receive the function.
operations[].tableloot-table objectRequired for replace_tableReplace 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.

FieldTypeDefaultMeaning
functionidentifierRequiredRegistered loot-function ID.
conditionsarray of loot conditionsEmptyConditions checked before executing the function.
fromitem identifierRequired for replacementOnly this generated item is substituted.
targetsarray of objectsRequired, nonemptyWeighted replacement choices; does not alter pool selection probability.
targets[].itemitem identifierRequiredRegistered target; minecraft:air removes the result.
targets[].weightinteger1Positive relative weight; total must fit a signed integer.
targets[].mininteger-1-1 preserves the generated count; otherwise 0–2304.
targets[].maxintegerSame as minAt least min, at most 2304; both must be -1 to preserve count.
chancenumber1Finite probability 0–1, for either function.
copy_nbtbooleanfalseReplacement copies the old stack’s NBT when enabled.
defaultrule objectClear allDefault NBT removal rule.
default.clear_allbooleantrueRemove all NBT; ignores strip patterns.
default.strip_keysarray of regex stringsEmptyFull-match top-level key patterns, used when clear_all is false.
overridesarray of objectsEmptyItem-specific NBT rules; later duplicate item wins.
overrides[].itemitem identifierRequiredRegistered item for this rule.
overrides[].rulerule objectDefault ruleReplacement rule for this item.
overrides[].rule.clear_allbooleanInherited from defaultWhether to clear all NBT.
overrides[].rule.strip_keysarray of regex stringsEmptyFull-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.