Quick Start
Get started with INJ - a powerful extension for Minecraft functions
Installation
To get started with INJ, follow these steps:
Install Node.js
Install Node.js - the runtime environment required for INJ
Download INJ
Download INJ for your operating system (Windows, macOS, or Linux)
Extract the downloaded file
Navigate to the INJ root directory (where package.json is located)
Run node install.js in your terminal to set up INJ
After installation, you can use the inj command from any directory in your terminal.
File Structure
INJ follows the same file structure as Minecraft datapacks. Your source directory (typically named src) mirrors the structure of a datapack's data folder:
Place your src directory alongside the data folder in your datapack. Edit files directly in src, then compile using:
INJ Syntax
INJ enhances Minecraft functions by allowing you to write JavaScript code alongside Minecraft commands. While knowing JavaScript can help you unlock INJ's full potential, you only need to understand a few basic concepts to get started:
Running Minecraft Commands
You can directly write Minecraft commands in any line of your INJ code:
You can also use $() to execute Minecraft commands. This function is particularly useful when you need to incorporate JavaScript variables into your commands:
Advanced Example: Creating Shapes
Here's how to create a circle of arrows using JavaScript math functions:
Conditional Logic
You can use if statements to add conditional logic to your code. The conditions can be written in pure JavaScript syntax. For Minecraft-specific conditions, write them as JavaScript strings, such as "block ~ ~ ~ minecraft:air" or "score @r inj_score = 3".
There are three ways to write conditions:
if (<minecraft_condition>) {}if (<js_condition>) {}if (<minecraft_condition>.and(<js_condition>)) {}
Note: You can use either and() or or() to combine conditions.
The rest of the if statement syntax follows standard JavaScript conventions.
Loops
While INJ supports both for and while loops, while loops currently only work with JavaScript conditions:
We will be supporting mixed JavaScript and Minecraft conditions for while loops in the future.
Here's another example showing how to create a line of stone using a for loop:

And an arrow circle:

For more advanced JavaScript concepts and features, refer to MDN Web Docs.