VillagerEntityHelper
com.jsmacrosce.jsmacros.client.api.helper.world.entity.VillagerEntityHelper
A villager helper exposing the villager's profession, type, level and experience.
The trade list is not available from the entity on the client; see MerchantEntityHelper.getTrades() for the client-side source of displayed offers.
js
const villagers = World.getEntities("villager");
if (villagers !== null) {
for (const entity of villagers) {
if (!(entity instanceof EntityHelpers.Villager)) continue;
Chat.log(`a level ${entity.getLevel()} ${entity.getProfession()} `
+ `holding ${entity.getExperience()} xp`);
}
}Available in scripts as EntityHelpers.Villager.
Constructors
new VillagerEntityHelper
Methods
getLevel
Returns the villager's trading level, clamped by the game to a minimum of one and with five as the maximum. This is distinct from accumulated trading experience, returned by getExperience().
Returns: this villager's trading level, from one to five
getProfession
getStyle
Returns the villager's biome type, which determines its appearance rather than its profession. This is the holder's
toString() representation, not a stable registry id; use the biome at the villager's position to identify where it currently stands.Returns: the holder's own string form for this villager's biome type