Skip to content
Find file
Fetching contributors…
Cannot retrieve contributors at this time
29 lines (24 sloc) 921 Bytes
(ns cljminecraft.entity
(:require [cljminecraft.util :as util]))
(def entitytypes (util/map-enums org.bukkit.entity.EntityType))
(defn get-entities [world & {:keys [type-keys living?]}]
(let [entclasses
(filter #(not (nil? %))
(map #(if-let [t (get entitytypes %)] (.getEntityClass t))
(if (coll? type-keys) type-keys [type-keys])))]
(if (not-empty entclasses)
(.getEntitiesByClasses world (into-array Class entclasses))
(.getLivingEntities world)
(.getEntities world)))
(defn find-entity [nm]
(let [names (map #(name (first %)) entitytypes)]
(filter #(.contains % (.toLowerCase nm)) names)))
(defn spawn-entity [location entityname]
(let [type (get entitytypes (keyword entityname))]
(when (and type (.isSpawnable type))
(.spawnEntity (.getWorld location) location type))))
Jump to Line
Something went wrong with that request. Please try again.