Wiki 9Minecraft Rhino Mod Wiki
Rhino Mod Wiki › Guide

Rhino Mod — Guide

Technical Architecture

Rhino works by converting JavaScript code into Java classes at runtime. This allows scripts to interact with Minecraft's underlying Java code with minimal performance overhead. The mod utilizes the Architectury API to ensure cross-platform compatibility between Forge, Fabric, and NeoForge loaders.

Core Engine Features

Feature Description
ES6 Support Supports modern JavaScript syntax including arrow functions, classes, and template literals.
Java Interop Seamlessly wraps Minecraft and Forge/Fabric classes into JavaScript objects.
Class Mapping Automatically handles obfuscated mappings, allowing developers to use clean names in scripts.
Reflection Optimization Uses optimized reflection to access private fields and methods within the Minecraft source.
No Nashorn Dependency Operates independently of the built-in Java scripting engine, preventing crashes on newer Java versions.

Scripting Mechanics

Rhino categorizes scripts into three distinct types based on when and where they are executed. Upon the first run, the mod generates a kubejs/ folder in the Minecraft directory containing these subdirectories:

Script Types

  1. Startup Scripts (startup_scripts/) * Execution: Loaded once during the initial game launch. * Purpose: Used for registering new blocks, items, and entities. These cannot be fully reloaded without a game restart because they interact with the game's registry system. * Reloading: Use /kubejs reload startup_scripts (limited functionality).

  2. Server Scripts (server_scripts/) * Execution: Loaded when a world or server starts. * Purpose: Used for modifying recipes, loot tables, tags, and handling server-side events (e.g., player login, block breaking). * Reloading: Use the /reload command to refresh all data and scripts.

  3. Client Scripts (client_scripts/) * Execution: Loaded on the player's local machine. * Purpose: Used for visual changes, tooltips, JEI/REI integration, and asset modification. * Reloading: Use F3 + T or /kubejs reload client_scripts.

Content Registration Framework

While Rhino is a library, it provides the API that allows users to define custom content. Through the Rhino engine, developers can register the following components:

Custom Blocks and Items

Developers can define properties for new blocks and items using JavaScript objects. The engine handles the conversion to Minecraft's internal registry.

Supported Block Properties: * Hardness and Resistance * Light Level (Luminance) * Tool Requirements (Pickaxe, Axe, etc.) * Custom Shapes and Hitboxes * Sound Types (Stone, Wood, Grass)

Supported Item Properties: * Max Stack Size * Rarity (Common, Uncommon, Rare, Epic) * Burn Time (Fuel efficiency) * Tool Level and Attack Speed * Custom Tooltips and Glow Effects

Entity and Mob Handling

Rhino enables the creation of custom entity handlers. While it doesn't add a "Rhino Mob," it allows scripts to define behaviors for existing or new entities, including: * Spawn Logic: Controlling where and when mobs appear. * Drops: Modifying loot tables dynamically based on the killer or weapon used. * Stats: Adjusting health, movement speed, and follow range via attribute modifiers.

Recipe and Data Management

Rhino's primary use case in modpacks is the manipulation of recipes. It supports any mod that utilizes standard Minecraft datapack recipes (JSON format).

Recipe Modification Capabilities

  • Addition: Create new shaped, shapeless, smelting, blasting, or smoking recipes.
  • Removal: Remove recipes by ID, output item, or input ingredient.
  • Transformation: Modify ingredients during crafting (e.g., damaging a tool instead of consuming it, or returning an empty bucket).
  • Mod Support: Native support for complex mods like Create, Mekanism, and Thermal Series through specialized addon scripts.

Tag Management

Rhino allows for the dynamic editing of Tags (Item Tags, Block Tags, Fluid Tags, and Entity Type Tags). This is essential for cross-mod compatibility, ensuring that "Copper Ingots" from different mods are treated as the same item in recipes.