entity
you get an entity value from Katton.world().entities, or as the return value of Katton.world().spawnEntity(...). players are not included here, they're exposed separately via player values (see player) and Katton.world().players
properties
entity.uuid //"8667ba71-b85a-4004-af54-457a9734eed7" as a string
entity.type //"zombie"
entity.is_valid //true / false. an entity can stop existing at any point, whether it dies, despawns, etc. once that happens, every method below (other than the properties) throws a runtime error so check first if the `entity` value still exists
entity.location //{ x: 12.5, y: 64.0, z: -3.0, yaw: 90.0, pitch: 0.0 }
entity.health //20.0, living entities only
entity.max_health //20.0, living entities only
entity.tags //a list of scoreboard tag strings
entity.vehicle //a `entity` value for whatever they are riding
entity.yaw //living entities only
entity.pitch //living entities only
methods
entity.setHealth(health)
entity.setDisplayName(text)
display.setSkin(username)
entity.teleport(location)
entity.setGlowing(glowing = true)
entity.addTag(tag)
entity.removeTag(tag)
entity.hasTag(tag)
entity.setMovementSpeed(speed)
entity.resetMovementSpeed()
entity.setJumpStrength(strength)
entity.resetJumpStrength()
display.setScale(x, y, z) or entity.setScale(scale)
entity.resetScale()
display.setText(text)
display.setBackgroundColor(r, g, b, a)
display.resetBackground()
display.setDefaultBackground(enabled)
display.setTextOpacity(opacity)
display.setAlignment(alignment)
display.setLineWidth(width)
display.setSeeThrough(seeThrough)
display.setShadowed(shadowed)
display.setBillboard(billboard)
display.setItem(item)
display.setBlock(material)
display.setOffset(x, y, z)
display.setRotation(yaw, pitch, roll)
display.setTeleportDuration(ticks)
display.setInterpolationDuration(ticks)
display.setInterpolationDelay(ticks)
entity.giveEffect(potion_effect)
entity.removeEffect(potion_effect)
entity.removeAllEffects()
thisEntity.mount(entity)
thisEntity.dismount()
entity.kill()
setHealth
sets the entity's current health
entity.setHealth(health)
Note
living entities only. value is clamped between 0 and the entity's max_health
example
val zombie = Katton.world().spawnEntity("zombie", player.location)
zombie.setHealth(5)
setDisplayName
sets the custom name tag displayed above the entity
entity.setDisplayName(text)
Note
passing "" hides the name tag
example
zombie.setDisplayName("&c&lBOSS ZOMBIE")
setSkin
sets the entity's skin if the entity is a mannequin
display.setSkin(username)
Note
only works on mannequins
example
mannequin.setSkin("yayAmelia")
teleport
teleports the entity to a target location object
entity.teleport(location)
example
zombie.teleport({ "x": 0, "y": 70, "z": 0, "yaw": 0, "pitch": 0 })
setGlowing
enables or disables the vanilla outline glowing effect around the entity
entity.setGlowing(glowing = true)
example
zombie.setGlowing(true)
zombie.setGlowing(false)
addTag
adds a scoreboard tag to the entity
entity.addTag(tag)
Note
scoreboard tags are handy for marking specific entities your script spawned so you can tell them apart from everything else in the world later
example
val zombie = Katton.world().spawnEntity("zombie", player.location)
zombie.addTag("boss_fight_mob")
for (e in Katton.world().entities) {
if (e.hasTag("boss_fight_mob")) {
e.setGlowing(true)
}
}
removeTag
removes a scoreboard tag from the entity
entity.removeTag(tag)
Note
removeTag does nothing if the tag was never there
hasTag
checks if the entity has a scoreboard tag
entity.hasTag(tag)
setMovementSpeed
modifies movement speed attribute base values
entity.setMovementSpeed(speed)
Note
living entities only
example
zombie.setMovementSpeed(0.3)
resetMovementSpeed
resets movement speed attribute base values to default
entity.resetMovementSpeed()
Note
living entities only
setJumpStrength
modifies jump height attribute base values
entity.setJumpStrength(strength)
Note
living entities only
example
zombie.setJumpStrength(0.6)
resetJumpStrength
resets jump height attribute base values to default
entity.resetJumpStrength()
Note
living entities only
setScale
resizes the display entity along each coordinate axis or modifies the living entity's scale attribute
display.setScale(x, y, z) or entity.setScale(scale)
Note
only works on display entities for 3 axis scale, or living entities for attribute scale
example
val display = Katton.world().spawnEntity("block_display", player.location)
display.setBlock("stone")
display.setScale(1, 3, 1)
resetScale
resets the scale configuration back to default
entity.resetScale()
setText
sets the text content displayed by a text display entity
display.setText(text)
Note
only works on text display entities (text_display)
example
val display = Katton.world().spawnEntity("text_display", player.location)
display.setText("hello world")
setBackgroundColor
changes the background color of a text display entity
display.setBackgroundColor(r, g, b, a)
Note
only works on text display entities (text_display)
example
display.setBackgroundColor(255, 0, 0, 128)
resetBackground
resets the background color of a text display entity
display.resetBackground()
Note
only works on text display entities (text_display)
example
display.resetBackground()
setDefaultBackground
configures whether the default background is enabled for a text display entity
display.setDefaultBackground(enabled)
Note
only works on text display entities (text_display)
example
display.setDefaultBackground(false)
setTextOpacity
sets the opacity of the text on a text display entity
display.setTextOpacity(opacity)
Note
only works on text display entities (text_display)
example
display.setTextOpacity(128)
setAlignment
sets the text alignment on a text display entity
display.setAlignment(alignment)
Note
only works on text display entities (text_display)
example
display.setAlignment("left")
setLineWidth
sets the maximum line width for wrapping text on a text display entity
display.setLineWidth(width)
Note
only works on text display entities (text_display)
example
display.setLineWidth(300)
setSeeThrough
enables or disables whether the text display is visible through blocks
display.setSeeThrough(seeThrough)
Note
only works on text display entities (text_display)
example
display.setSeeThrough(true)
setShadowed
enables or disables the text shadow effect on a text display entity
display.setShadowed(shadowed)
Note
only works on text display entities (text_display)
example
display.setShadowed(true)
setBillboard
sets the billboard setting of the text display entity
display.setBillboard(billboard)
Note
only works on text display entities (text_display)
example
display.setBillboard("fixed")
setItem
sets the item stack displayed by an item display entity
display.setItem(item)
Note
only works on item display entities (item_display). see item for making items
example
val display = Katton.world().spawnEntity("item_display", player.location)
display.setItem(Katton.item("diamond_sword"))
setBlock
sets the block material displayed by a block display entity
display.setBlock(material)
Note
only works on block display entities (block_display)
example
val display = Katton.world().spawnEntity("block_display", player.location)
display.setBlock("stone")
setOffset
shifts the display entity relative to the entity's actual pivot point without moving the entity itself
display.setOffset(x, y, z)
Note
only works on display entities (item_display, block_display, text_display)
example
val display = Katton.world().spawnEntity("block_display", player.location)
display.setBlock("stone")
display.setOffset(0, 2, 0)
setRotation
rotates the display model using degrees
display.setRotation(yaw, pitch, roll)
Note
only works on display entities (item_display, block_display, text_display)
example
val display = Katton.world().spawnEntity("item_display", player.location)
display.setItem(Katton.item("diamond_sword"))
display.setRotation(0, 45, 90)
setTeleportDuration
sets the teleport tick duration for position changes to transition smoothly instead of snapping immediately
display.setTeleportDuration(ticks)
Note
only works on display entities (item_display, block_display, text_display)
example
display.setTeleportDuration(20)
setInterpolationDuration
sets the interpolation duration
display.setInterpolationDuration(ticks)
Note
only works on display entities (item_display, block_display, text_display)
setInterpolationDelay
sets the interpolation delay
display.setInterpolationDelay(ticks)
Note
only works on display entities (item_display, block_display, text_display)
giveEffect
gives the entity a potion effect
entity.giveEffect(potion_effect)
removeEffect
removes a specific potion effect from the entity
entity.removeEffect(potion_effect)
removeAllEffects
removes all active potion effects from the entity
entity.removeAllEffects()
mount
makes the entity mount an entity
thisEntity.mount(entity)
dismount
makes the entity stop riding whatever they are currently riding
thisEntity.dismount()
kill
removes the entity immediately from the world
entity.kill()
example
zombie.kill()