#How to apply potion effects to entities within a certain area?

3 messages · Page 1 of 1 (latest)

mortal cloud
#

player.potionEffects.add() exists for players, but not for general entities from what I've looked at with ProbeJS

ItemEvents.firstRightClicked(event => {
  const { item, level, player, entity } = event
  if (item.getId() == 'kubejs:final_axe') {
    let fangBox = AABB.of(
      player.pos.x() - 20,
      player.pos.y() - 5,
      player.pos.z() - 20,
      player.pos.x() + 20,
      player.pos.y() + 10,
      player.pos.z() + 20
    )
    level.getEntitiesWithin(fangBox).forEach(entity => {
      switch (entity.getType()) {
        case null: return
        case 'minecraft:item': return
        case 'minecraft:lightning_bolt': return
        case 'minecraft:end_crystal': return
        case 'minecraft:area_effect_cloud': return
        case 'minecraft:falling_block': return
        case 'minecraft:evoker_fangs': return
        case 'minecraft:item_frame': return
        case 'minecraft:glow_item_frame': return
        default:
          if (!entity.isPlayer()) {
            if (event.player.isShiftKeyDown()) {
              // entity.potionEffects.add() doesn't seem to exist or work
              entity.block.createEntity('minecraft:evoker_fangs').spawn()
            }
          }
          break;
      }
    })
  }
})
unkempt spearBOT
#

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

mortal cloud
#

Nvm it's a duplicate (found my answer in a previous ticket) and ProbeJS is just... not showing it