#How to make this const identify all entities, including the player?

1 messages · Page 1 of 1 (latest)

analog jasper
#
world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location})```
slender path
#

Because of this

#
      const entities = player.dimension.getEntities({location: player.location, maxDistance: 2})
      entities.forEach(entity => {
    
        entity.applyKnockback(-entity.getViewDirection().x, -entity.getViewDirection().z, 1, 0)
    
    
      })
analog jasper
#
const entities = world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location, excludeNames:[player.name]})```
slender path
analog jasper
#

no

#

if u imported world

#

u should be fine

analog jasper
slender path
#

Continues without identifying surrounding entities, including the player

analog jasper
#

its working for me

#

do u have it in a system.runInterval?

#

its like a forcefield effect

slender path
#

@analog jasper

  const tick = mc.system.runInterval(() => {

    try {
      const entities = mc.world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location})
      entities.forEach(entity => {
    
        entity.applyKnockback(-entity.getViewDirection().x, -entity.getViewDirection().z, 1, 0)
    
    
      })


    } catch {

      mc.system.clearRun(tick)


    }



  }, 1)
analog jasper
slender path
analog jasper
#

cause this is what i have it rn

const entities = world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location, excludeNames:[player.name]})```
#

then define the player.location

slender path
#

I want knockback to be added to it too

analog jasper
#

if its applyed always then u have to look the opposite way u want to go

#

but u gotta still define player

#

like this

for (const player of world.getPlayers()) {
//put ur code here
}```
#

this is what its suppose to be

const tick = system.runInterval(() => {

    try {
        for (const player of world.getPlayers()) {
      const entities = world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location})
      entities.forEach(entity => {
    
        entity.applyKnockback(-entity.getViewDirection().x, -entity.getViewDirection().z, 1, 0)
    
    
      })


    }} catch {

      system.clearRun(tick)


    }



  }, 1)```
trail blaze
#

xD