Clojure API for Minecraft/Bukkit
Clojure API for Minecraft/Bukkit
Server-specific set-block implementation
Server-specific set-block implementation
(add this that)
(add this that & more)
Add multiple vector/location-like things together. Returns a value with the same type of the first argument.
Add multiple vector/location-like things together. Returns a value with the same type of the first argument.
(add-inventory player item)
(add-inventory player item n)
Add the named item to the player's inventory, or n copies of it
Add the named item to the player's inventory, or n copies of it
(block block-or-loc)
Get the block at the given location, returns a Clojure map. See get-block
if you need the actual block object.
Get the block at the given location, returns a Clojure map. See [[get-block]] if you need the actual block object.
Map from keyword to block.Action value
Map from keyword to block.Action value
(block-face kw)
Coerce to BlockFace
Use to convert keywords like :east/:west/:self to BlockFace instances. Idempotent.
Coerce to BlockFace Use to convert keywords like :east/:west/:self to BlockFace instances. Idempotent.
Map from BlockFace value to keyword
Map from BlockFace value to keyword
Map from keyword to BlockFace value
Map from keyword to BlockFace value
(block-set coll)
(block-set xform coll)
Create a block set, a set of maps where every :x/:y/:z value can only occur once.
Create a block set, a set of maps where every :x/:y/:z value can only occur once.
(clear-weather)
(clear-weather world)
Get clear weather
Get clear weather
(create-world name opts)
Create a new world with a given name and options
Create a new world with a given name and options - :seed long - :structures? boolean - :hardcore? boolean
(default-world)
World used for commands when no explicit world is given.
Uses *default-world*
, or the first world on the server.
World used for commands when no explicit world is given. Uses [[*default-world*]], or the first world on the server.
(direction block-or-loc)
Get the direction of a Block, or of the block at a certain location.
Get the direction of a Block, or of the block at a certain location.
(distance this that)
Get the euclidian distance between two locations. Can take various bukkit
objects (Location, Block, Vector), as well as Clojure vectors [x y z]
or
maps {:x x :y y :z z}
, and any combination thereof.
Get the euclidian distance between two locations. Can take various bukkit objects (Location, Block, Vector), as well as Clojure vectors `[x y z]` or maps `{:x x :y y :z z}`, and any combination thereof.
Make sure there is only one block for each coordinate in the set, and keep them sorted by x/z/y.
Make sure there is only one block for each coordinate in the set, and keep them sorted by x/z/y.
Map from keyword to EntityType value
Map from keyword to EntityType value
(fast-forward time)
(fast-forward world time)
Fast forward the clock, time is given in ticks, with 20 ticks per second, or 24000 ticks in a Minecraft day.
Fast forward the clock, time is given in ticks, with 20 ticks per second, or 24000 ticks in a Minecraft day.
(fly!)
(fly! player)
Set a player as allowing flight and flying. Note: doesn't seem to actually cause flying, but it does make flying possible.
Set a player as allowing flight and flying. Note: doesn't seem to actually cause flying, but it does make flying possible.
(food-level player)
Get the player's food level, a number between 0 and 20
Get the player's food level, a number between 0 and 20
(game-mode)
(game-mode player)
Get the current game mode
Get the current game mode
(get-block loc)
Get the block at a given location. Idempotent.
Get the block at a given location. Idempotent.
(-display-name _)
(-set-display-name _ _)
(-location _)
Get the location of the given object
Get the location of the given object
(-world-by-name _ _)
(-world-by-uuid _ _)
(-worlds _)
(health player)
Get the player's health, a number between 0 and 20
Get the player's health, a number between 0 and 20
(highest-block-at loc)
Retrieve the highest block at the given location
Retrieve the highest block at the given location
(in-front-of loc)
(in-front-of loc n)
Get the location n
blocks in front of the given location, based on the
location's direction. Polymorphic, can work with most things that have a
location. Returns plain data.
Get the location `n` blocks in front of the given location, based on the location's direction. Polymorphic, can work with most things that have a location. Returns plain data.
(init-xmaterial!)
We can only access the XMaterial class once a Bukkit server is available
We can only access the XMaterial class once a Bukkit server is available
(inventory player)
Get the player's inventory
Get the player's inventory
(item-stack material count)
Create an ItemStack object
Create an ItemStack object
(listen! event k f)
Listen for an event
Event is a keyword based on the event type, like :player-interact
or
:item-spawn
, k`` is a key this event is registered under, so you can
unlisten!` with the same key afterwards. Re-registering a listener with the
same event and key will replace the old listener.
See (keys
lambdaisland.witchcraft.events/events
)
for all known
events.
Listen for an event Event is a keyword based on the event type, like `:player-interact` or `:item-spawn`, `k`` is a key this event is registered under, so you can `unlisten!` with the same key afterwards. Re-registering a listener with the same event and key will replace the old listener. See `(keys `[[lambdaisland.witchcraft.events/events]]`)` for all known events.
(loc obj)
Get the location of a thing, as a clojure map. Can take most objects that have some kind of location, e.g. Location, Player, Vector, Block, Entity. Can also take Clojure maps or vectors, so you can use it to coerce input of unknown type.
Get the location of a thing, as a clojure map. Can take most objects that have some kind of location, e.g. Location, Player, Vector, Block, Entity. Can also take Clojure maps or vectors, so you can use it to coerce input of unknown type.
(location o)
Get the location of the given object
Get the location of the given object
Map from XMaterial value to keyword
Map from XMaterial value to keyword
Map from keyword to XMaterial value
Map from keyword to XMaterial value
(online-players)
List all online players
List all online players
(player)
(player name)
Get a player by name, or simply the first player found.
Get a player by name, or simply the first player found.
(player-chunk player)
Return the chunk the player is in
Return the chunk the player is in
For the rare API calls that really want a plugin instance
For the rare API calls that really want a plugin instance
(plugin-manager)
Get the Bukkit plugin manager
Get the Bukkit plugin manager
(x _)
(chunk _)
Retrieve the chunk for a location, entity, etc.
Retrieve the chunk for a location, entity, etc.
(-add this that)
Add locations, vectors, etc. That can also be a map of :x
, :y
, :z
Add locations, vectors, etc. That can also be a map of `:x`, `:y`, `:z`
(y _)
(with-xyz _ xyz)
Return the same type, but with x/y/z updated
Return the same type, but with x/y/z updated
(material-data _)
(direction-vec _)
(entities _)
Get the chunk's entities
Get the chunk's entities
(yaw _)
(pitch _)
(material-name _)
(as-vec _)
Coerce to org.bukkit.util.Vector
Coerce to org.bukkit.util.Vector
(z _)
(material _)
(redo!)
Redo the last build that was undone with undo!
Redo the last build that was undone with [[undo!]]
(remove-inventory player item)
(remove-inventory player item n)
Remove the named items from the player's inventory, or n copies of it
Remove the named items from the player's inventory, or n copies of it
(run-task f)
Schedule a task for the next server tick
Schedule a task for the next server tick
(run-task-later f ticks)
Schedule a task for after n ticks
Schedule a task for after n ticks
(send-message p message)
Send a chat message to a specific player
Takes strings or vectors (markup), e.g.
[:red "hello " [:underline "world"]]
See [[markup/codes]].
Send a chat message to a specific player Takes strings or vectors (markup), e.g. ``` [:red "hello " [:underline "world"]] ``` See [[markup/codes]].
(send-title p title)
(send-title p title subtitle)
Send a title and optionally subtitle to the player
Titles are splashed in big type over the middle of the screen, before they fade out.
Takes strings or vectors (markup), e.g.
[:red "hello " [:underline "world"]]
See [[markup/codes]].
Send a title and optionally subtitle to the player Titles are splashed in big type over the middle of the screen, before they fade out. Takes strings or vectors (markup), e.g. ``` [:red "hello " [:underline "world"]] ``` See [[markup/codes]].
(server)
Get the currently active server.
Get the currently active server.
(set-bed-spawn-location player loc)
(set-bed-spawn-location player loc force?)
Set the location where the player will respawn, set force?
to true to update
the spawn location even if there is no valid bed available.
Set the location where the player will respawn, set `force?` to true to update the spawn location even if there is no valid bed available.
(set-block loc)
(set-block loc material)
Set the block at a specific location to a specific material
material
can be a keyword (see materials
), a String like RED_WOOL
or
WOOL:14
, a bukkit Material, a Bukkit ItemStack, or an xseries XMaterial.
Set the block at a specific location to a specific material `material` can be a keyword (see [[materials]]), a String like `RED_WOOL` or `WOOL:14`, a bukkit Material, a Bukkit ItemStack, or an xseries XMaterial.
(set-blocks blocks)
(set-blocks blocks {:keys [keep-history?]})
Set blocks in bulk
Takes a sequence of maps with :x, :y, :z, :material, and optionally :world and :data.
Currently only optimized on Glowstone, elsewhere it repeatedly calls set-block
Set blocks in bulk Takes a sequence of maps with :x, :y, :z, :material, and optionally :world and :data. Currently only optimized on Glowstone, elsewhere it repeatedly calls [[set-block]]
(set-direction loc dir)
Set the direction of a block, takes a keyword or BlockFace,
see block-faces
Set the direction of a block, takes a keyword or BlockFace, see [[block-faces]]
(set-food-level player food-level)
Set the player's food level, a number between 0 and 20
Set the player's food level, a number between 0 and 20
(set-game-rule wrld kw bool)
Set a game rule like :do-daylight-cycle
or :do-insomnia
.
See (keys wc/game-rule-types)
for all options
Set a game rule like `:do-daylight-cycle` or `:do-insomnia`. See `(keys wc/game-rule-types)` for all options
(set-game-rules world m)
Set multiple game rules like :do-daylight-cycle
or :do-insomnia
.
See (keys wc/game-rule-types)
for all options. Takes a map from keyword to
bool.
Set multiple game rules like `:do-daylight-cycle` or `:do-insomnia`. See `(keys wc/game-rule-types)` for all options. Takes a map from keyword to bool.
(set-health player health)
Set the player's health, a number between 0 and 20
Set the player's health, a number between 0 and 20
(set-time time)
(set-time world time)
Set the time in a world, or the first world on the current server. Time is given in ticks, with 20 ticks per second, or 24000 ticks in a Minecraft day.
Set the time in a world, or the first world on the current server. Time is given in ticks, with 20 ticks per second, or 24000 ticks in a Minecraft day.
(start-glowstone! & args)
Start an embedded Glowstone server
Optionally provided with a map of config options. See [[lambdaisland.witchcraft.config/key-values]]
Start an embedded Glowstone server Optionally provided with a map of config options. See [[lambdaisland.witchcraft.config/key-values]]
(start-paper! & [gui?])
Start an embedded PaperMC server
Start an embedded PaperMC server
(teleport loc)
(teleport entity l)
Teleport to a given location
Teleport to a given location
(time)
(time world)
Get the current time in the world in ticks.
Get the current time in the world in ticks.
Map from keyword to TreeSpecies value
Map from keyword to TreeSpecies value
(undo!)
Undo the last build. Can be repeated to undo multiple builds.
Undo the last build. Can be repeated to undo multiple builds.
(unlisten! event k)
Remove an event listener
Remove an event listener
(vec3 x y z)
Create a org.bukkit.util.Vector instance
Create a org.bukkit.util.Vector instance
(world o)
(world o n)
Get the world associated with a given object, or look up a world by string or UUID.
Get the world associated with a given object, or look up a world by string or UUID.
(xmaterial m)
Get an XMaterial instance from a keyword, string, Material, or ItemStack, or anything else for which the polymorphic [[material]] method is implemented.
This is a shim class which provides version-independent material handling.
Get an XMaterial instance from a keyword, string, Material, or ItemStack, or anything else for which the polymorphic [[material]] method is implemented. This is a shim class which provides version-independent material handling.
(xyz o)
Get the x/y/z values of an object as a vector, can work with maps containing
:x
/:y
/:z
keys, or virtually any Glowstone object that encodes or has a
location.
Get the x/y/z values of an object as a vector, can work with maps containing `:x`/`:y`/`:z` keys, or virtually any Glowstone object that encodes or has a location.
(xyz1 o)
Like xyz
, but add an extra 1
at the end, for affine transformations
Like [[xyz]], but add an extra `1` at the end, for affine transformations
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close