Compatibility
Minecraft: Java Edition
Platforms
Supported environments
75% of ad revenue goes to creators
Support creators and Modrinth ad-free with Modrinth+Creators
Details
Overview
Unleash the power of JSON-based scripting in Minecraft with this mod. Whether you're creating custom gameplay mechanics, managing player data, or handling complex logic, this mod provides all the tools you need. Packed with instructions, math functions, event handling, and entity manipulation, it simplifies scripting so you can focus on building your Minecraft world without getting lost in the code. Everything is in a file called 'crun.json'
Features
- Core Instructions: Set, get, and manipulate variables, data, and more.
- Mathematical Functions: A wide range of math operations, from basic arithmetic to advanced functions like sine, cosine, and logarithms.
- Event Handling: Easily trigger actions based on player interactions, health, or other events.
- Entity Management: Access and modify player and entity properties seamlessly.
- Randomization: Generate random numbers for unique and dynamic gameplay experiences.
- Boolean Logic: Use advanced boolean operators to control game flow based on conditions.
- Buttons: The 'Reload' buttons added to the title and pause screen, can be disabled in crun.json
Why Use This Mod?
- Streamlined Scripting: Simplifies complex actions into easy-to-use instructions.
- Customization: Tailor the game mechanics to fit your vision, whether you're a modder or a server admin.
- Efficiency: Focus on gameplay without bogging down in convoluted coding.
Documentation
0. How to add events
- In crun.json create a json object called 'code'
- In the 'code' json object, create another object with the name of the event (e.g. onPlayerTick)
- Add code to the new json object.~~~~
1. Key Concepts
- JSON: A way to store data in key-value pairs.
- Objects: Containers for data (e.g., Player, Level).
- Numbers: Numeric values (e.g., health, score).
- Text (Strings): Used for messages, names, etc.
- Keys/Values: Keys identify data; values hold the actual data.
2. Instructions vs Methods
- Instructions: Actions performed in the system (e.g., SET, GET).
- Methods: Functions that give back values (e.g., getHealth).
3. Core Instructions and Methods
GET_ARG
- Purpose: Gets arguments from an event.
- Usage:
GET_ARG 0
(Grabs the first argument, e.g., Player).
SET
- Purpose: Saves a value to a variable.
- Usage:
SET Player aVeryLongNameForThePlayerLivingEntity: GET_ARG 0
(Stores the Player from GET_ARG 0 into a variable).
GET
- Purpose: Gets a value from a variable.
- Usage:
GET aVeryLongNameForThePlayerLivingEntity
(Retrieves the Player saved earlier).
XX
- Purpose: Allows using the same instruction multiple times.
- Usage:
SET bool variable1 XX0: GET somethingElse
(XX helps you repeat instructions without issues).
CONSTANT
- Purpose: Used for fixed values that don’t change (e.g., numbers, strings).
- Usage:
CONSTANT-INT 10
(Represents the number 10).
BASIC MATH OPERATIONS
-
ADD: Adds two numbers.
MATH ADD [GET playerHealth] [CONSTANT-FLOAT 0.02]
-
SUB: Subtracts the second number from the first.
MATH SUB [GET playerHealth] [CONSTANT-FLOAT 0.02]
-
MUL: Multiplies two numbers.
MATH MUL [GET playerHealth] [CONSTANT-FLOAT 1.05]
-
DIV: Divides the first number by the second.
MATH DIV [GET playerHealth] [CONSTANT-FLOAT 0.95]
-
POW: Raises the first number to the power of the second.
MATH POW [GET playerHealth] [CONSTANT-FLOAT 2]
-
ROUND: Rounds the number to the nearest integer.
MATH ROUND [GET playerHealth]
ADVANCED MATH OPERATIONS
-
SIN: Sine of a number (in radians).
MATH SIN [GET playerAngle]
-
COS: Cosine of a number (in radians).
MATH COS [GET playerAngle]
-
TAN: Tangent of a number (in radians).
MATH TAN [GET playerAngle]
-
ASIN: Arc sine (inverse sine).
MATH ASIN [GET playerAngle]
-
ACOS: Arc cosine (inverse cosine).
MATH ACOS [GET playerAngle]
-
ATAN: Arc tangent (inverse tangent).
MATH ATAN [GET playerAngle]
-
EXP: Exponential function (e^x).
MATH EXP [GET playerHealth]
-
LOG: Natural logarithm (base e).
MATH LOG [GET playerHealth]
-
LOG10: Logarithm to the base 10.
MATH LOG10 [GET playerHealth]
-
SQRT: Square root of a number.
MATH SQRT [GET playerHealth]
-
CBRT: Cube root of a number.
MATH CBRT [GET playerHealth]
-
IEEEREMAINDER: Computes the remainder (IEEE 754 standard).
MATH IEEEREMAINDER [GET playerHealth] [CONSTANT-FLOAT 2]
-
CEIL: Ceiling function (rounds up).
MATH CEIL [GET playerHealth]
-
FLOOR: Floor function (rounds down).
MATH FLOOR [GET playerHealth]
-
RINT: Rounds the number to the nearest integer, ties rounding to the even choice.
MATH RINT [GET playerHealth]
CONVERSIONS
-
TO_RAD: Converts degrees to radians.
MATH TO_RAD [GET playerAngle]
-
TO_RADIANS: Converts degrees to radians (same as TO_RAD).
MATH TO_RADIANS [GET playerAngle]
-
TO_DEG: Converts radians to degrees.
MATH TO_DEG [GET playerAngle]
-
TO_DEGREES: Converts radians to degrees (same as TO_DEG).
MATH TO_DEGREES [GET playerAngle]
CONSTANTS
-
PI: The value of pi (3.14159...).
MATH PI
-
E: The value of e (2.71828...).
MATH E
RANDOM
- RANDOM: Generates a random number between 0 and 1.
MATH RANDOM
BOOLEAN OPERATORS
-
NOT: Negates a value.
NOT [GET isPlayerHealthLow]
-
AND: Both conditions must be true.
AND [GET isPlayerHealthLow] [GET isPlayerNearDanger]
-
OR: One condition must be true.
OR [GET isPlayerHealthLow] [GET isPlayerNearDanger]
-
NAND: Both conditions must not be true.
NAND [GET isPlayerHealthLow] [GET isPlayerNearDanger]
(Returns true if at least one condition is false). -
NOR: Both conditions must not be true.
NOR [GET isPlayerHealthLow] [GET isPlayerNearDanger]
(Returns true if both conditions are false). -
XOR: Exactly one condition must be true.
XOR [GET isPlayerHealthLow] [GET isPlayerNearDanger]
(Returns true if one condition is true, but not both). -
XNOR: Both conditions must be either true or false.
XNOR [GET isPlayerHealthLow] [GET isPlayerNearDanger]
(Returns true if both conditions are the same).
COMPARE
- Purpose: Compares values and returns a boolean.
- Usage:
COMPARE SMALLER [GET playerHealth] [CONSTANT-FLOAT 0.5]
(Checks if player's health is less than 50%). - What exists: SMALLER, BIGGER, EQUAL
IF
- Purpose: Conditional execution.
- Usage:
"IF XX0": {
"condition": "GET isPlayerHealthLow",
"true": {
"SET int someVariable": "GET_ARG 2"
},
"false": {
"SET int someVariable": "GET_ARG 1"
}
}
METHOD and METHOD_CALL
- Purpose: (Calls functions, not methods) Functions return values;
METHOD_CALL
executes functions with no return value. - Example:
SET float health: METHOD player.getHealth()
(Gets the player's health).
METHOD_CALL XX1: METHOD player.setHealth([GET newHealth])
(Sets the player's health to a new value).
4. Data Types
- int: Integer numbers (e.g., 1, -3).
- short: Small integer values (e.g., 10, -50).
- long: Very large integer values.
- float: Decimal numbers with 6-7 digits of precision.
- double: Hyper-precise decimal numbers with 15-16 digits of precision.
- String: Text, such as player names or messages.
- boolean: True or false values.
- Player: The player entity
- LivingEntity: Something that's alive. (Includes the Player)
- Entity: Includes things like: Cow, Arrow, Primed Tnt... (Includes every living entity)
- Vec3: It has 3 double values: x y z. Used for position, velocity...
Event list
- onPlayerTick: Player player
- onPlayerHurt: Player player, UNSUPPORTED source, double amount
- onPlayerAttack: Player player, Entity target
- onPlayerDie: Player player, UNSUPPORTED cause
- onPlayerWakeUp: Player player, boolean wakeImmediately, boolean updateLevelForSleepingPlayers
Function list
- Player has all functions of LivingEntity and Entity
- LivingEntity has all functions of Entity
- Entity.discard()
- Entity.kill()
- Entity.turn(double yRot, double xRot)
- Entity.clearFire()
- Entity.extinguishFire()
- Entity.onGround() -> boolean
- Entity.isSilent() -> boolean
- Entity.setSilent(boolean silent)
- Entity.isNoGravity() -> boolean
- Entity.setNoGravity(boolean noGravity)
- Entity.fireImmune() -> boolean
- Entity.isInWater() -> boolean
- Entity.isInWaterOrRain() -> boolean
- Entity.isInWaterRainOrBubble() -> boolean
- Entity.isInWaterOrBubble() -> boolean
- Entity.isUnderWater() -> boolean
- Entity.isInLava() -> boolean
- Entity.isPickable() -> boolean
- Entity.isPushable() -> boolean
- Entity.isAlive() -> boolean
- Entity.isInWall() -> boolean
- Entity.isOnFire() -> boolean
- Entity.isPassenger() -> boolean
- Entity.isVehicle() -> boolean
- Entity.dismountsUnderwater() -> boolean
- Entity.isShiftKeyDown() -> boolean
- Entity.isSteppingCarefully() -> boolean
- Entity.isSuppressingBounce() -> boolean
- Entity.isDiscrete() -> boolean
- Entity.isDescending() -> boolean
- Entity.isCrouching() -> boolean
- Entity.isSprinting() -> boolean
- Entity.isSwimming() -> boolean
- Entity.isVisuallySwimming() -> boolean
- Entity.isVisuallyCrawling() -> boolean
- Entity.hasGlowingTag() -> boolean
- Entity.isCurrentlyGlowing() -> boolean
- Entity.isInvisible() -> boolean
- Entity.isOnRails() -> boolean
- Entity.getMaxAirSupply() -> int
- Entity.getAirSupply() -> int
- Entity.setAirSupply(int airSupply)
- Entity.getTicksFrozen() -> int
- Entity.getPercentFrozen() -> float
- Entity.isFullyFrozen() -> boolean
- Entity.getTicksRequiredToFreeze() -> int
- Entity.isInvulnerable() -> boolean
- Entity.setInvulnerable(boolean newValue)
- Entity.canChangeDimensions() -> boolean
- Entity.getMaxFallDistance() -> int
- Entity.displayFireAnimation() -> boolean
- Entity.getStringUUID() -> String
- Entity.setDeltaMovement(double x, double y, double z); set the player velocity
- Entity.setDeltaMovement(Vec3 value); set the player velocity
- Entity.getDeltaMovement() -> Vec3; get the player velocity
- Entity.addDeltaMovement(Vec3 value); add to the player velocity
- Entity.getRemainingFireTicks() -> int
- Entity.setRemainingFireTicks(int value)
- LivingEntity.getHealth() -> float
- LivingEntity.setHealth(float newHealth)
- Player.isSecondaryUseActive() -> boolean
- Player.getPortalWaitTime() -> int
- Player.getScore() -> int
- Player.setScore(int value)
- Player.increaseScore(int value)