#LootJS

50 messages · Page 1 of 1 (latest)

cyan valley
#

Does anyone know how to replace an item with lootjs (within a loot table), where you copy the nbt data from the item thats being replaced to the new item?

alpine scaffoldBOT
#

Once your ticket has been resolved, please close it with </ticket close:1054771505520717835> command!

rapid sleetBOT
#

You can write your code in a codeblock by typing it between the codeblock delimiters:
Note that these are backticks, not apostrophes

```js :arrow_left:

ServerEvents.recipes(event => {
event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})

``` :arrow_left:

This example will look like this:

ServerEvents.recipes(event => {
  event.smelting('minecraft:glass', '#forge:sand').xp(.1)
})
cyan valley
#
    ["reliquary:inject/chests/desert_pyramid",
        "apotheosis:chests/chest_valuable",
        "betterfortresses:chests/quarters",
        "minecraft:chests/desert_pyramid",
        "artifacts:inject/chests/spawn_bonus_chest",
        "artifacts:inject/chests/woodland_mansion",
        "quark:blocks/lootr_bamboo_chest",
        "minecraft:chests/jungle_temple_dispenser",
        "irons_spellbooks:chests/citadel/wall_loot",
        "twilightforest:chests/troll_garden",
        "bloodmagic:chests/standard_dungeon/strong_alchemy",
        "irons_spellbooks:chests/filler_storage_loot",
        "quark:blocks/prismarine_trapped_chest",
        "irons_spellbooks:chests/priest_house",
    ].forEach((loot_p) => {
        let flint_armor = LootEntry.tag("#kubejs:armor/flint").randomChance(0.5).setQuality(1).enchantWithLevels([3, 10]);;
        let osmium_armor = LootEntry.tag("#kubejs:armor/osmium").randomChance(0.3).setQuality(1).enchantWithLevels([20, 30]);
        event.addLootTableModifier(loot_p).addEntry(flint_armor);
        event.addLootTableModifier(loot_p).addEntry(osmium_armor);
        event.addLootTableModifier(loot_p).removeLoot(ItemFilter.tag("#forge:armor/diamond"));
        event.addLootTableModifier(loot_p).removeLoot(ItemFilter.tag("#forge:armor/iron"));
    }); 
winter grail
#

is that your entire code thing

#

you need LootJS.modifiers((event) => {

#

i think

#

i cant really tell what ur tying to do rn couldyou explain more in depth

cyan valley
#

i have it as a wrapper this is inside of it

#

what im trying to do is remove all diamond/iron armor from these loot tables, and add the tags with flint and osmium armor

winter grail
cyan valley
#

yes

winter grail
#

it looks like there is nothing for that you'd have to manually add them

#

you can remove them all from diamond/iron armor with event.removeAllTagsFrom

cyan valley
#

each armor piece has to be added?

cyan valley
winter grail
#
  event.removeAllTagsFrom(minecraft:iron_chestplate)
cyan valley
#

but i want to remove it from the loot table

#

not replacing tags sorry

winter grail
#

what do you want to remove from the loot table

#

you cant remove tags from a loot table?

cyan valley
#

diamond armor and iron armor

winter grail
#

wait

#

ohhhh

cyan valley
#

and then put in osmium armor and flint armor

winter grail
#

LootJS.modifiers((event) => {
event.removeLoot("minecraft:flint");
});

#

try that

#

wait you wanted replacement?

cyan valley
#

replacement yes but i want to specify it

#

also shouldn't i be modifying the loot table that i want?

#

or does event.removeLoot remove from everything?

winter grail
#
LootJS.modifiers((event) => {
    event.replaceLoot("minecraft:flint","minecraft:diamond");
});
#

idk if it needs an itemfilter tho

cyan valley
#

hmm, I'm trying to add an item in with enchantments

#

LootEntry.tag("#kubejs:armor/flint").randomChance(0.5).setQuality(1).enchantWithLevels([3, 10]); i was looking at making an entry

winter grail
#

this is all very confusing for me sorry lol

cyan valley
#

its all good,

#

what im trying to do is

#

i have a list of loot tables

#

i want to remove diamond/iron armor from them

#

then make an entry for the loot table with enchantments specified above, and then put them into the loot table

winter grail
#

idk the enchant thing tho

cyan valley
#

sounds good

#

i got it to work

#

read the changelogs for 1.20.1

#

addloottable modifer has an attribute that allows u to directly add an entry

#

i achieved my solution with the following:

event.addLootTableModifier(loot_table).replaceLoot(Item.of('minecraft:iron_helmet').ignoreNBT(), LootEntry.of('pickletweaks:flint_helmet').enchantWithLevels([3,10]), true);