#naming all specific entity's

1 messages · Page 1 of 1 (latest)

cobalt jackal
#
import { system, world, Entity } from "@minecraft/server";

// Function to update the name of all pigs
function renameAllPigs() {
    // Iterate through all entities in the world
    for (const entity of world.getEntities()) {
        // Check if the entity is a pig
        if (entity.id === "minecraft:pig") {
            // Set the name tag of the pig to "hi"
            entity.nameTag = "hi";
        }
    }
}

// Run the update function every second (20 ticks)
system.runInterval(renameAllPigs, 20);
cobalt jackal
wide bough
#

entity.typeId === 'minecraft:pig'

cobalt jackal
wide bough
#
import { system, world, Entity } from "@minecraft/server";

// Function to update the name of all pigs
function renameAllPigs() {
    // Iterate through all entities in the world
    for (const entity of world.getDimension('overworld').getEntities()) {
        // Check if the entity is a pig
        if (entity.id === "minecraft:pig") {
            // Set the name tag of the pig to "hi"
            entity.nameTag = "hi";
        }
    }
}

// Run the update function every second (20 ticks)
system.runInterval(renameAllPigs, 20);
#

You have to get the dimension then get the entities from that dimension

cobalt jackal
#

ohhhh

#

thanks

warped crater
wide bough
warped crater
wide bough
#

Maybe the original code was AI generated

warped crater