Skip to content
setupminimal edited this page Jun 23, 2015 · 1 revision

Cljsh mods get passed an instance of Cljsh's main object, which has these helpful methods:

;; For all of these, a-clojure-function must be a function of one variable, 
;; and will be called with the triggering event

(.addInitializationCallback a-clojure-function)  
;; Will call the function when initialization occurs

(.addPostInitializationCallback a-clojure-function) 
;; Will call the function when post-initialization occurs

(.addRegularCallback EventClass a-clojure-function) 
;; Will call the function whenever an event of type EventClass is fired on the standard event bus

(.addFMLCallback EventClass a-clojure-function)
;; Will call the function whenever an event of type EventClass is fired on the FML bus

(.addTerrainGenCallback EventClass a-clojure-function)
;; Will call the function whenever an event of type EventClass is fired on the TerrainGen bus

(.addOreGenCallback EventClass a-clojure-function)
;; Will call the function whenever an event of type EventClass is fired on the OreGen bus

Using these methods, a mod can easily register to intercept all the events they need to, and can call normal GameRegistry methods to register blocks, items, etc.

Here is the general structure of a Cljsh mod:

(import stuff.needed.from.Forge)

;; Helper functions
(defn registerSomething . . .)
(defn handleAnEvent . . .)

;; Main function
(defn main [instance]
  (. instance addInitializationCallback registerSomething)
  (. instance addRegularCallback handleAnEvent))

;; This gets run during pre-initialization
(fn [x] (main x))

Clone this wiki locally