Wiki 9Minecraft Wiki 9Minecraft

Code Chicken Lib Developer API

Guides 7FAQ 11Related mods 60
DownloadCodeChicken Lib

Get the files on 9Minecraft

Contents (5)
  1. Declaring the dependency
  2. 3D math example
  3. Custom packet example
  4. Next guides
  5. More in this wiki

Modders depend on Code Chicken Lib to avoid re-implementing math, rendering, networking, and config plumbing. Add it as a dependency, then use its APIs.

Declaring the dependency

Declare Code Chicken Lib as a required dependency in your mod descriptor so the game enforces correct load order, and reference it from your build configuration.

3D math example

import codechicken.lib.vec.Vector3;
import codechicken.lib.vec.Matrix4;

Vector3 dir = new Vector3(1, 0, 0);
Matrix4 m = new Matrix4().rotate(Math.PI / 2, Vector3.Y_POS);
dir.apply(m); // dir is now rotated 90 degrees about the Y axis

Custom packet example

import codechicken.lib.packet.PacketCustom;

// build and send a packet to a player
PacketCustom packet = new PacketCustom(MY_CHANNEL, 1);
packet.writePos(pos);
packet.writeInt(value);
packet.sendToPlayer(player);

Always compile and test against the exact Code Chicken Lib version your release targets - the API surface can change between game versions.