#.explosionMode('mob') causes damage to the environment for some reason

7 messages · Page 1 of 1 (latest)

viscid zenith
#

I see that there are 4 modes:

  • "NONE"
  • "BLOCK"
  • "MOB"
  • "TNT"
    none does nothing to mobs or blocks as expected...
    block destroys the terrain as expected (I'm assuming tnt is similar)

But then when it comes to mob it's expected that it only damages mobs but in reality it also damages the terrain as well which is what I don't want

Code below:

ItemEvents.rightClicked(event => {
  const { item, level, player, entity } = event
  let myBoundingBox = AABB.of(
    player.pos.x() - 20,
    player.pos.y() - 10,
    player.pos.z() - 20,
    player.pos.x() + 20,
    player.pos.y() + 10,
    player.pos.z() + 20
  )
  if (item.getId() == 'kubejs:final_sword') {
    level.getEntitiesWithin(myBoundingBox).forEach(entity => {
      if (entity == null) { return }
      if (entity.item) { return }
      switch (entity.getType()) {
        case 'minecraft:lightning_bolt': return
        case 'minecraft:end_crystal': return
        case 'minecraft:area_effect_cloud': return
        case 'minecraft:falling_block': return
        default:
          break;
      }
      if (!entity.isPlayer()) {
        entity.block.createExplosion()
          .exploder(entity)
          .explosionMode('mob')
          .causesFire(false)
          .strength(3)
          .explode();
      }
    })
  }
})
spare scrollBOT
#

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

viscid zenith
#

Unless if I'm not understanding the explosion modes clearly hmmm

woeful fable
#

explosionMode is what the game treats as the origin of the explosion, mob will check for the mobGreifing gamerule, and tnt doesn't have any block decay

#

none will result in no block damage. the issue here is that entities aren't damaged by their own explosion, so you need to pass player to .exploder() instead

viscid zenith
#

Ohhh I see

viscid zenith
#

Yup that works ty ^-^