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);
#naming all specific entity's
1 messages · Page 1 of 1 (latest)
im trying to name all the pigs in the world to hi but it wont work.
entity.typeId === 'minecraft:pig'
hmm it still wont name the pigs hi
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
The comments tbh looks like ai generated lmal
I just copied the original message's code
I know but I'm nor saying you coded it, I'm saying it looks ai lmao
Maybe the original code was AI generated
Probably cause of unnecessary usage of function :(