Skip to content
Matias Bjarland edited this page Dec 6, 2017 · 7 revisions

Writing and Running a Basic Mod

Requirements

  • forge-clj needs to be set up as described in the previous tutorial.
  • Some basic knowledge of Clojure.

Instructions

  • In your core.clj file, you now need to write the namespace declaration. Your namespace is equivalent to your package in java, for those who know it. Otherwise, an example would be (assuming you named the folders as I described in the previous tutorial):
(ns <yourusername>.<yourmodname>.core)
  • This will tell Clojure where you are and what your file's name is. However, in order to make a mod, we need to use the defmod macro from forge-clj.core in order to make a mod! Because of this, you need to modify this declaration to say this:
(ns <yourusername>.<yourmodname>.core
  (:require
    [forge-clj.core :refer [defmod]]))
  • This tells Clojure that we're using the forge-clj.core namespace, and that we're using defmod from that namespace. There are a few other ways to include things from other namespaces (other files), but this is fine.

  • Now we actually need to make the mod itself. The defmod macro works as follows:

(defmod <namespace> <modname> "<modversion>")
  • This will make a Mod file that Minecraft Forge can recognize. It is created within the namespace you specify, with the mod name and mod version (in quotations!) specified.

  • You should now have a mod! To run your mod, open the console, navigate to the folder that has build.gradle in it, and run the command ./gradlew runClient on mac/linux, or gradlew runClient on windows.

  • If Minecraft boots, well done! You should now have a mod. To make sure you actually do, click the Mods button, and see if your mod is in the list of Mods. If it is, that means you can move on to the next tutorial!

  • As an example, here is a sample. The name in this case is yoshiquest, the mod name is test-mod, and the version is "0.0.1"

(ns yoshiquest.test-mod.core
  (:require
    [forge-clj.core :refer [defmod]]))

(defmod yoshiquest.test-mod.core test-mod "0.0.1")
  • As a side note, when your mod is complete and ready to be tested on a normal minecraft installation/is ready to be distributed, be sure to run ./gradlew build or gradlew build before doing so. The jar created by runClient is broken if used outside of the development environment for some reason, so just be sure to build first.

  • Up next, we'll add proxies so our mod will actually do something!

Clone this wiki locally