#How to make this const identify all entities, including the player?
1 messages · Page 1 of 1 (latest)
I want it to continue working as a const
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)
})
const entities = world.getDimension("overworld").getEntities({maxDistance: 2, location: player.location, excludeNames:[player.name]})```
Does World get dimision not need to be inside any event?
did it work for u?
Is not working
Continues without identifying surrounding entities, including the player
its working for me
do u have it in a system.runInterval?
its like a forcefield effect
Yea
@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)
did u define player.location?
No
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
But I don't want the player to be deleted
I want knockback to be added to it too
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)```
xD