//所有生物掉1到3个绿宝石
NativeEvents.onEvent($LivingDeathEvent, event => {
  let entity = event.entity
  if (entity && entity.isLiving() && entity.isMonster() && !entity.persistentData.getBoolean('apple_emerald') ){
    let entityName = entity.type
    let count = Math.floor(Math.random() * 3) + 1;
    entity.block.popItem(Item.of('minecraft:emerald', count))

    if (stage_boss_2_1.includes(entityName) ||
      stage_boss_2_2.includes(entityName) ||
      stage_boss_3.includes(entityName)
    ) {
      entity.block.popItem(Item.of('minecraft:enchanted_golden_apple', 10))
    }

    entity.persistentData.putBoolean('apple_emerald', true)
  }
})
ServerEvents.entityLootTables(event => {
  //琥珀珍品
  event.modifyEntity("alexscaves:tremorsaurus", Loot => {
    Loot.addPool(pool => {
      pool.addItem('alexscaves:amber_curiosity')
    })
  })
  //活化金属
  event.modifyEntity('jerotesvillage:fury_second_rounder_animated_armor', Loot => {
    Loot.addPool(pool => {
      pool.addItem('kubejs:activated_metal').randomChance(0.3)
    })
  })
  event.modifyEntity('jerotesvillage:second_rounder_animated_armor', Loot => {
    Loot.addPool(pool => {
      pool.addItem('kubejs:activated_metal').randomChance(0.3)
    })
  })
  //燃料
  event.modifyEntity('pasterdream:terrorbeak', Loot => {
    Loot.addPool(pool => {
      pool.addItem('pasterdream:nightmare_fuel').count([0, 3])
    })
  })
  //咒翼
  event.modifyEntity("cataclysm:maledictus", Loot => {

    Loot.addPool(pool => {
      pool.addItem('2x kubejs:zhou_yi')
    })
  })
  //掠夺者
  event.modifyEntity('minecraft:pillager', Loot => {

    Loot.addPool(pool => {
      pool.addItem('minecraft:emerald').count([1, 4])
    })
  })
  //冥界骑士
  event.modifyEntity('block_factorys_bosses:underworld_knight', Loot => {

    Loot.addPool(pool => {
      pool.addItem('kubejs:underworld_ingot').count([1, 4])
    })
  })
  //末影龙
  event.modifyEntity('minecraft:ender_dragon', Loot => {

    Loot.addPool(pool => {
      pool.addItem('minecraft:dragon_egg')
    })
  })
  //末影合金锭
  event.modifyEntity('cataclysm:ender_guardian', Loot => {

    Loot.addPool(pool => {
      pool.addItem('10x cataclysm:enderite_block')
    })
  })
  //下界之星
  event.modifyEntity('legendary_monsters:withered_abomination', Loot => {

    Loot.addPool(pool => {
      pool.addItem('3x minecraft:nether_star')
    })
  })
  //利维坦肉块
  event.modifyEntity('cataclysm:the_leviathan', Loot => {

    Loot.addPool(pool => {
      pool.addItem('2x kubejs:abyssal_tentacles')
      pool.addItem('2x kubejs:leviathan_meat')
    })
  })
  //撼地斯拉
  event.modifyEntity('alexscaves:tremorzilla', Loot => {

    Loot.addPool(pool => {
      //撼地斯拉肉块
      pool.addItem('2x kubejs:tremorzilla_meat')
      //铀质突刺
      pool.addItem('3x kubejs:uranium_spurs')
    })
  })
  //古老梦华/下界之星
  event.modifyEntity('minecraft:wither', Loot => {

    Loot.addPool(pool => {
      pool.addItem('kubejs:monochrome')
      pool.addItem('minecraft:nether_star')
    })
  })
  //金属碎屑
  event.modifyEntity('pasterdream:shadow_golem', Loot => {

    Loot.addPool(pool => {
      pool.addItem('3x pasterdream:rust_black_metal_grain')
    })
  })
  //巨兽排气孔
  event.modifyEntity('cataclysm:netherite_monstrosity', Loot => {

    Loot.addPool(pool => {
      pool.addItem('kubejs:harbinger_exhaust_vents')
    })
  })
  //头颅
  event.modifyEntity('cataclysm:aptrgangr', Loot => {

    Loot.addPool(pool => {
      pool.addItem('cataclysm:aptrgangr_head')
    })
  })
  //头颅
  event.modifyEntity('born_in_chaos_v1:pumpkinhead', Loot => {

    Loot.addPool(pool => {
      pool.addItem('born_in_chaos_v1:fel_lamp')
    })
  })
  //头颅
  event.modifyEntity('born_in_chaos_v1:lord_pumpkinhead_head', Loot => {

    Loot.addPool(pool => {
      pool.addItem('born_in_chaos_v1:lord_pumpkinheads_lamp')
    })
  })
  event.modifyEntity('minecraft:wither', Loot => {
    Loot.addPool(pool => {
      pool.addItem('2x art_of_forging:fragment_of_eden')
    })
  })
})
