#Multiple LootJS entries?

41 messages · Page 1 of 1 (latest)

junior wasp
#

The goal: Modify entity loot tables for multiple mobs.

The code:

    event
        .addEntityLootModifier("minecraft:piglin_brute")
        .addLoot(LootEntry.of("dotcoinmod:copper_coin").limitCount([2, 6]))
        .randomChance(0.1)
        .addLoot("dotcoinmod:iron_coin")

})

LootJS.modifiers((event) => {
        event
        .addEntityLootModifier("minecraft:ender_dragon")
        .addWeightedLoot([1, 1], [
            LootEntry.of("dotcoinmod:gold_coin").withChance(80),
            LootEntry.of("dotcoinmod:platinum_coin").withChance(20)])
})```

The problem: This isn't working, and neither is combining both entries under one event.

This is definitely 101-level problems but my brain has melted after crunching for the past month on other code stuff and I have no idea what simple thing I'm supposed to do here 😅
surreal forgeBOT
#

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

full zenith
#

try changing all those LootEntry.of to Item.of

#

here's what I'd try

LootJS.modifiers((event) => {
  event
    .addEntityLootModifier("minecraft:piglin_brute")
    .addWeightedLoot([2,6], [
      "dotcoinmod:copper_coin"
    ])
    .randomChance(0.1)
    .addLoot("dotcoinmod:iron_coin")

  event
    .addEntityLootModifier("minecraft:ender_dragon")
    .addWeightedLoot([
      Item.of("dotcoinmod:gold_coin").withChance(80),
      Item.of("dotcoinmod:platinum_coin").withChance(20)
    ])
})
junior wasp
#

Hmm. That's working with other mobs, but looks like it isn't working with the dragon specifically.

full zenith
#

could try going back to LootEntry on those ones

#

I think it was the .limitCount in the first one that was maybe off

#

were any errors showing up in logs/kubejs/server.txt?

junior wasp
#

Hmmm. LootEntry is coming up with the same result, and no errors in the log

full zenith
#

Might have to wait for the dev to pop in with a better answer, we've reached the end of my knowledge 🙂

#

you actually spawning and killing it every time to try? If you're using something like JER to check loot tables those don't update

junior wasp
#

Looks like I'm hitting a conflict with another mod somewhere that's preventing the dragon from producing any drops. I'm testing both with the summon command and the end crystal ritual and not getting any drops even with a datapack.

full zenith
#

uh oh

junior wasp
#

200+ mod modpack in it's final stretches 😅

full zenith
#

I know those pains

junior wasp
#

I've a got a few likely candidates, though, so hopefully not too bad. Thanks a million for the help! It's definitely saved me a lot of work on other bosses I wanted to add loot to (they're all working)

full zenith
#

off the top of my head.... moredragoneggs, MA, and maybe quark... but they're all additive and shouldn't mess with the current pool

junior wasp
#

I've got Savage Ender Dragon which makes some heavy changes to the dragon fight and Paragliders which adds some special loot spawning for that fight.

full zenith
#

Could be that the dragon doesn't actually have a loot table.... if anything, you could fake it with an EntityEvents.Death()

#

no, looks like it does.... hmmmm

junior wasp
#

I'm not opposed to faking it if there's a workaround 👀

full zenith
#
EntityEvents.death("minecraft:ender_dragon", event => {
  const {entity, level} = event
  itemEntity = level.createEntity("item")
  itemEntity.x = entity.x
  itemEntity.y = entity.y
  itemEntity.z = entity.z
  if (Utils.Random.nextInt(100) > 20) {
    itemEntity.item = Item.of("dotcoinmod:gold_coin")
  } else {
    itemEntity.item = Item.of("dotcoinmod:platinum_coin")
  }
  itemEntity.item.count = 1
  itemEntity.spawn()
})

something like that

#

but if you don't find a mod futzing with it, it might just be we have written in wrong in lootjs

#

@dire tiger might be up in a couple hours and hopefully takes a look

junior wasp
#

I'm getting an unknown event error for EntityEvents.Death 🤔 I'm assuming I've got it in the right place popping it in the server scripts?

full zenith
#

yep

#

sigh

#

lowercase death

#

fixed my codeblock

junior wasp
#

AH

#

I literally just spotted that 😂

#

I was like "I wonder if? 🤔" 😅

full zenith
#

sometimes when I write examples I do lots of testing.... sometimes I pull a "I got this, no need to test"

junior wasp
#

Yup. That loaded fine. Lemme go murder some dragons real quick

full zenith
#

you can guess which one this was haha

junior wasp
#

😂 dizzyTen

#

Looks like that did it! I can at least move forward with this workaround for now

dire tiger
#

The dragon may not trigger a loot table. You can enable debugging in lootjs and see if the table will be logged

surreal forgeBOT
#

@junior wasp Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!

surreal forgeBOT
#

@junior wasp Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!

surreal forgeBOT
#

@junior wasp Unresolved thread still hasn't been closed! If your question was answered, please close this post with </ticket close:1054771505520717835> command!