Entities & Players
The OOP module models Minecraft entities and players as Kotlin objects with selectors and context-aware extension functions.
Creating entities
player() creates a Player instance (subclass of Entity) with type = minecraft:player, limit = 1, and the given name. entity() creates a generic Entity with custom selector arguments, and can also start from a named entity selector when you already know the exact entity name to target.
Use player(...) when you want a selector already scoped to players, and entity { ... } when you need a reusable selector for mobs, armor stands, projectiles, or a more generic execute target. Use entity("Name", ...) when you want the same convenience as player("Name") without forcing the selector to minecraft:player.
Execute helpers
Entity-scoped execute shortcuts emit /execute as, /execute at, or both:
These helpers are especially valuable when you would otherwise repeat the same execute as, execute at, or execute as ... at ... boilerplate around several commands.
Batch
batch() creates a named sub-function that groups multiple commands under a single entity context:
batch() is a good fit for onboarding flows, class kits, respawn setup, or any repeated multi-command routine that should stay grouped under one entity context.
Entity Commands
Extension functions on Entity for common Minecraft commands:
| Function | Description |
|---|---|
addTag |
Add a scoreboard tag |
clearItems |
Clear inventory (optionally filtered) |
damage |
Deal damage with optional damage type |
dismount |
Dismount from current vehicle |
giveItem |
Give an item stack |
giveXp |
Add experience (levels or points) |
kill |
Kill the entity |
mount |
Mount another entity |
playSound |
Play a sound at the entity |
removeTag |
Remove a scoreboard tag |
replaceItem |
Replace an item in a specific slot |
sendMessage |
Send a tellraw message |
setGamemode |
Change the player's gamemode |
setXp |
Set experience to an exact value |
showActionBar |
Display text on the action bar |
showTitle |
Display a title and optional subtitle |
teleportTo |
Teleport to coordinates or another entity |
Practical pattern
This combines one reusable player selector with several entity-scoped actions, which is the core value of the OOP entity API.
Entity Effects
Extension functions on Entity for giving, clearing, and managing mob effects:
| Function | Description |
|---|---|
giveEffect |
Give a timed effect with optional amp |
giveInfiniteEffect |
Give an infinite-duration effect |
clearEffect |
Remove a specific effect |
clearAllEffects |
Remove all effects |
effects { ... } |
Builder block for multiple operations |
