I’m attempting to have modded objects within the chests of misplaced cites mod, and there may be this drawback I’m dealing with, through which a mod referred to as Apocalypse Now mechanically injects its mod objects into the chests with out having a necessity of datapack, which suggests its being accomplished internally throughout the mod. What I’ve discovered is that it’s overwriting loot tables totally and by that, lootjs/kubejs or the datapacks of the one other mod doesn’t inject their itmes.
That one other mod is Timeless and Classics Zero, and I made the datapacks and the json file (later) for this mods by taking assist of a number of chatbots, since I lack data on making datapacks or json file for the lootjs/kubejs to overwrite or simply add your loot to the loot tables with out overwriting it. I’ll have the contents of these recordsdata written down beneath, by which you’ll be able to see if there are errors or not in these 3 recordsdata.
- Datapack for the timeless and classics zero mod:
a. add_tacz_apartment.json
"sort": "forge:add_items",
"circumstances": [
{
"condition": "forge:loot_table_id",
"loot_table_id": "minecraft:chests/apartament"
}
],
"objects": [
{
"item": "tacz:modern_kinetic_gun",
"weight": 100,
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:glock_17",GunCurrentAmmoCount:7}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "Glock 17",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 6,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:uzi",GunCurrentAmmoCount:25}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "Uzi",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 6,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:db_short",GunCurrentAmmoCount:2}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "Sawed-off",
"italic": false
}
}
]
},
{
"merchandise": "tacz:sight_uh1",
"weight": 8
},
{
"merchandise": "tacz:sight_552",
"weight": 8
},
{
"merchandise": "tacz:muzzle_silencer_phantom_s1",
"weight": 4
},
{
"merchandise": "tacz:muzzle_compensator_trident",
"weight": 4
},
{
"merchandise": "tacz:ammo_9mm",
"weight": 12
},
{
"merchandise": "tacz:ammo_12g",
"weight": 10
},
{
"merchandise": "tacz:ammo_45acp",
"weight": 4
}
]
}
b. add_tacz_lostcitychest.json
"sort": "forge:add_items",
"circumstances": [
{
"condition": "forge:loot_table_id",
"loot_table_id": "lostcities:chests/lostcitychest"
}
],
"objects": [
{
"item": "tacz:modern_kinetic_gun",
"weight": 4,
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:ak47",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "AK-47 (abandoned)",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 6,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:db_short",GunCurrentAmmoCount:2}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "Sawed-off",
"italic": false
}
}
]
},
{
"merchandise": "tacz:sight_rmr_dot",
"weight": 4
},
{
"merchandise": "tacz:light_extended_mag_3",
"weight": 1
},
{
"merchandise": "tacz:ammo_9mm",
"weight": 12
},
{
"merchandise": "tacz:ammo_45acp",
"weight": 4
},
{
"merchandise": "tacz:ammo_12g",
"weight": 8
}
]
}
c. add_tacz_raildungeon.json
"sort": "forge:add_items",
"circumstances": [
{
"condition": "forge:loot_table_id",
"loot_table_id": "lostcities:chests/raildungeonchest"
}
],
"objects": [
{
"item": "tacz:modern_kinetic_gun",
"weight": 6,
"functions": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:ak47",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "AK-47 (abandoned)",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 3,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:sks_tactical",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "SKS (rifle)",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 3,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:type_81",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "Type 81",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 1,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:aa12",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "AA-12 (very rare)",
"italic": false
}
}
]
},
{
"merchandise": "tacz:modern_kinetic_gun",
"weight": 1,
"features": [
{
"function": "minecraft:set_nbt",
"tag": "{GunId:"tacz:m320",GunCurrentAmmoCount:0}"
},
{
"function": "minecraft:set_name",
"name": {
"text": "M320 (very rare)",
"italic": false
}
}
]
},
{
"merchandise": "tacz:scope_acog_ta31",
"weight": 4
},
{
"merchandise": "tacz:scope_vudu",
"weight": 3
},
{
"merchandise": "tacz:scope_mk5hd",
"weight": 1
},
{
"merchandise": "tacz:muzzle_brake_cyclone_d2",
"weight": 4
},
{
"merchandise": "tacz:sight_deltapoint_pistol",
"weight": 4
},
{
"merchandise": "tacz:ammo_556x45",
"weight": 10
},
{
"merchandise": "tacz:ammo_762x39",
"weight": 10
},
{
"merchandise": "tacz:ammo_30_06",
"weight": 4
},
{
"merchandise": "tacz:ammo_45_70",
"weight": 2
}
]
}
- loot_integration.json (file for kubejs/lootjs)
// Defensive LootJS injector — tries a number of API names and catches all errors.
// Exchange your present file with this. It is not going to throw TypeError on lacking strategies.
(operate() {
operate log() {
attempt { console.log("[KubeJS-LOOTFIX]", Array.prototype.be a part of.name(arguments, " ")); } catch (e) {}
}
// Gadgets to inject (similar lists you used)
const taczItemsApartment = [
{ item: "tacz:sight_uh1", weight: 8 },
{ item: "tacz:sight_552", weight: 8 },
{ item: "tacz:muzzle_silencer_phantom_s1", weight: 4 },
{ item: "tacz:muzzle_compensator_trident", weight: 4 },
{ item: "tacz:ammo", weight: 12, nbt: '{AmmoId:"tacz:9mm"}' },
{ item: "tacz:ammo", weight: 10, nbt: '{AmmoId:"tacz:12g"}' },
{ item: "tacz:ammo", weight: 4, nbt: '{AmmoId:"tacz:45acp"}' },
{ item: "tacz:modern_kinetic_gun", weight: 8, nbt: '{GunId:"tacz:glock_17",GunCurrentAmmoCount:7}' },
{ item: "tacz:modern_kinetic_gun", weight: 6, nbt: '{GunId:"tacz:uzi",GunCurrentAmmoCount:25}' },
{ item: "tacz:modern_kinetic_gun", weight: 6, nbt: '{GunId:"tacz:db_short",GunCurrentAmmoCount:2}' }
];
const taczItemsRailDungeon = [
{ item: "tacz:scope_acog_ta31", weight: 4 },
{ item: "tacz:scope_vudu", weight: 3 },
{ item: "tacz:scope_mk5hd", weight: 1 },
{ item: "tacz:muzzle_brake_cyclone_d2", weight: 4 },
{ item: "tacz:sight_deltapoint_pistol", weight: 4 },
{ item: "tacz:ammo", weight: 10, nbt: '{AmmoId:"tacz:556x45"}' },
{ item: "tacz:ammo", weight: 10, nbt: '{AmmoId:"tacz:762x39"}' },
{ item: "tacz:ammo", weight: 4, nbt: '{AmmoId:"tacz:30_06"}' },
{ item: "tacz:ammo", weight: 2, nbt: '{AmmoId:"tacz:45_70"}' },
{ item: "tacz:modern_kinetic_gun", weight: 6, nbt: '{GunId:"tacz:ak47",GunCurrentAmmoCount:0}' },
{ item: "tacz:modern_kinetic_gun", weight: 3, nbt: '{GunId:"tacz:sks_tactical",GunCurrentAmmoCount:0}' },
{ item: "tacz:modern_kinetic_gun", weight: 3, nbt: '{GunId:"tacz:type_81",GunCurrentAmmoCount:0}' },
{ item: "tacz:modern_kinetic_gun", weight: 1, nbt: '{GunId:"tacz:aa12",GunCurrentAmmoCount:0}' },
{ item: "tacz:modern_kinetic_gun", weight: 1, nbt: '{GunId:"tacz:m320",GunCurrentAmmoCount:0}' }
];
const taczItemsLostCity = [
{ item: "tacz:sight_rmr_dot", weight: 4 },
{ item: "tacz:light_extended_mag_3", weight: 1 },
{ item: "tacz:ammo", weight: 12, nbt: '{AmmoId:"tacz:9mm"}' },
{ item: "tacz:ammo", weight: 4, nbt: '{AmmoId:"tacz:45acp"}' },
{ item: "tacz:ammo", weight: 8, nbt: '{AmmoId:"tacz:12g"}' },
{ item: "tacz:modern_kinetic_gun", weight: 4, nbt: '{GunId:"tacz:ak47",GunCurrentAmmoCount:0}' },
{ item: "tacz:modern_kinetic_gun", weight: 6, nbt: '{GunId:"tacz:db_short",GunCurrentAmmoCount:2}' }
];
// low-level helper: safely attempt to name a technique on occasion
operate tryCall(occasion, methodName, argsArray) {
attempt {
const fn = occasion[methodName];
if (typeof fn === "operate") {
return fn.apply(occasion, argsArray);
}
// If fn shouldn't be a JS operate, nonetheless try to name (some Java proxies enable direct name)
if (fn !== undefined) {
attempt { return fn(argsArray); } catch (e) { /* ignore */ }
}
} catch (e) {
// swallow errors so script does not crash
}
return null;
}
// helper: add objects utilizing a desk/context object
operate populateTableLikeObject(tblOrCtx, objects) {
attempt {
// most popular API: tblOrCtx.addPool(pool => { pool.addItem(...).withNBT(...) })
if (typeof tblOrCtx.addPool === "operate") {
tblOrCtx.addPool(operate(pool) {
// if pool.rolls exists, set single roll
attempt { if (typeof pool.rolls === "operate") pool.rolls([1,1]); } catch(e){}
objects.forEach(operate(entry) {
attempt {
if (entry.nbt && typeof pool.addItem === "operate") {
// chain withNBT if accessible
const e = pool.addItem(entry.merchandise, entry.weight || 1);
// some APIs return a wrapper with withNBT, others not - guard it
attempt { if (typeof e.withNBT === "operate") e.withNBT(entry.nbt); } catch(e){}
} else if (typeof pool.addItem === "operate") 1);
else if (typeof pool.add === "operate") {
// older variant: pool.add({ merchandise:..., weight:... })
pool.add( 1, nbt: entry.nbt );
}
} catch (errEntry) {
// skip problematic entry
}
});
});
return true;
}
// fallback: if ctx/desk has add or addItem strategies
if (typeof tblOrCtx.add === "operate") {
attempt { tblOrCtx.add(objects); return true; } catch(e) {}
}
if (typeof tblOrCtx.addItem === "operate") {
objects.forEach(operate(entry) {
attempt {
const e = tblOrCtx.addItem(entry.merchandise, entry.weight || 1);
attempt { if (entry.nbt && typeof e.withNBT === "operate") e.withNBT(entry.nbt); } catch(e){}
} catch(e){}
});
return true;
}
} catch (e) {
// swallow
}
return false;
}
// Tries a bunch of methodology names in defensive order. Returns true on first success.
operate tryModifyTable(occasion, tableId, objects) {
// candidate API names to attempt, so as
const candidates = [
"modifyLootTable",
"modify_table",
"modifyTable",
"modify",
"modify_loot_table"
];
for (let i = 0; i < candidates.size; i++) {
const title = candidates[i];
attempt {
// Try and name occasion[name](tableId, callback)
const res = tryCall(occasion, title, [tableId, function(tblOrCtx) {
const ok = populateTableLikeObject(tblOrCtx, items);
if (!ok) {
// As a fallback, try to call tblOrCtx.add(items)
try { if (typeof tblOrCtx.add === "function") tblOrCtx.add(items); } catch(e) {}
}
}]);
if (res !== null) {
log("Used API:", title, "for desk:", tableId);
return true;
}
} catch (err) {
// proceed attempting subsequent candidate
}
}
// Closing fallback: possibly occasion has an 'add' that accepts an object like { id, objects }
attempt {
if (typeof occasion.add === "operate") {
attempt { occasion.add({ id: tableId, objects: objects }); log("Used occasion.add fallback for", tableId); return true; } catch(e){}
}
} catch (e) {}
// As final resort, log occasion keys for debugging
attempt {
const keys = Object.keys(occasion).be a part of(", ");
log("No supported modify API discovered for desk", tableId, " — occasion keys:", keys);
} catch (e) {
log("No supported modify API discovered and could not checklist occasion keys.");
}
return false;
}
// Predominant entry: name inside LootJS.modifiers
LootJS.modifiers(operate(occasion) {
attempt {
let did1 = tryModifyTable(occasion, "minecraft:chests/apartament", taczItemsApartment);
let did2 = tryModifyTable(occasion, "lostcities:chests/raildungeonchest", taczItemsRailDungeon);
let did3 = tryModifyTable(occasion, "lostcities:chests/lostcitychest", taczItemsLostCity);
log("Injection outcomes — apartament:", !!did1, "raildungeon:", !!did2, "lostcity:", !!did3);
} catch (e) {
log("Sudden error inside LootJS.modifiers block:", String(e));
}
});
})();
I do not know if that is the place to ask this, I’ve requested this similar query in reddit however nobody replied, possibly on account of this problem being too technical. Please assist me with this.