#I need this to be executed in all entities...
1 messages · Page 1 of 1 (latest)
The getAllEntities that is throwing the error
I've tried before but I'll look again
It says that the entity is undefined
Expects 1 argument and receives 0
getAllEntities does not exist
it is world.getDimension('overworld').getEntities
Do I have to do it with all dimensions?
do you mean can you do it with all dimensions?
Yep
I need all dimensions
system.runInterval(() => {
for (let entity of world.getDimension('overworld').getEntities()) {
const cd = world.scoreboard.getObjective('ptw_atk_cd');
if (cd.getScore(entity) > 0) {
cd.addScore(entity, -1);
entity.addEffect("weakness", 3, { amplifier: 3, showParticles: false });
entity.addEffect("mining_fatigue", 3, { amplifier: 4, showParticles: false });
}
};
});
Is correct?
Did not work
[Scripting][error]-Error: Failed to resolve identity for '' at <anonymous> (Main.js:14)
import {world,World,system} from '@minecraft/server';
World.prototype.getAllEntities = function (){
const dimensionAll = ["overworld","nether","the end"].map(dimension=>world.getDimension(dimension))
return [...dimensionAll[0].getEntities(),...dimensionAll[1].getEntities(),...dimensionAll[2].getEntities()]
}
console.warn("Running");
system.run(() => {
world.scoreboard.getObjective("ptw_atk_cd") ?? world.scoreboard.addObjective("ptw_atk_cd", "attack_cooldown");
});
system.runInterval(() => {
for (let entity of world.getAllEntities()) {
const cd = world.scoreboard.getObjective('ptw_atk_cd');
if (cd.getScore(entity) > 0) {
console.log("Applying effects to entity");
cd.addScore(entity, -1);
entity.addEffect("weakness", 3, { amplifier: 3, showParticles: false });
entity.addEffect("mining_fatigue", 3, { amplifier: 4, showParticles: false });
}
}
});
[Scripting][error]-Error: Failed to resolve identity for '' at <anonymous> (Main.js:17)
if (cd.getScore(entity) > 0)```
Line 17
Did not work
if you explain what this "code" should do i could maybe help
...
It creates a scoreboard if it doesn't exist. Then, if the player's score is greater than 0, it reduces it by 1 and applies the weakness and fatigue effect.
This code works for players, but I want it to work for other entities too.
entity.scoreboardIdentity instead of just entity in getScore