QiHuang02's Notebook

website·Indexed 31 days ago

https://qihuang02.cn/

A collection of research notes and technical guides focusing on Minecraft modding. It includes detailed documentation for KubeJS (version 2101.7.0) and ProbeJS (version 7.4.0) on Minecraft 1.21.1, covering block and item registration, client/server/startup scripts, and the LootJS addon. The notebook also provides insights into Minecraft internals such as DataComponents, Codecs, Attributes, and Resource Packs.

Tokens
14.7K
Snippets
58
Records
108
Agent score
55%

What's inside QiHuang02's Notebook

  1. Overview of LootJS Loot Modifiers

    Loot Modifiers are events used to create modifiers that are applied when a loot table is sampled. This allows developers to directly process and modify the items generated by the loot table before they are delivered to the player or world.
  2. Overview of the Minecraft Codec framework

    Codec is a bidirectional data transformation framework developed by Mojang and integrated into Minecraft. It acts as a 'translator' between Java objects in memory and data formats used for storage and transmission, primarily JSON and NBT.

    Key workflows include:

    1. Encoding (Serialization): Java Object $\rightarrow$ Data Format (JSON/NBT). Used for saving world data or sending packets to clients.
    2. Decoding (Deserialization): Data Format (JSON/NBT) $\rightarrow$ Java Object. Used during game startup or resource loading from datapacks and world saves.
  3. Overview of LootJS for KubeJS

    LootJS is a KubeJS addon developed for NeoForge that allows developers to modify Minecraft loot tables using scripts. Because LootJS operates on the server side, all associated scripts must be placed in the server_scripts directory. It is compatible with Minecraft 1.21+.
  4. Overview of the Minecraft Resource Pack system

    The Resource Pack system allows players to customize textures, models, music, sounds, languages, fonts, and specific text elements (such as the End Poem, splash screens, and credits/copyright screens). Resource packs are frequently used in conjunction with data packs to add new content to the game.
  5. Understand the difference between Items and Blocks in Minecraft

    In Minecraft, a 'Block' refers to an object placed within the world (technically a BlockState). When a block is mined, it is removed (replaced by air) and drops an 'Item Entity'. This Item Entity is a physical entity in the world that can be affected by physics, such as being pushed by water or destroyed by fire and lava.
  6. Understand the Minecraft Block instance model

    Blocks are the fundamental building units of the Minecraft world. In the game engine, each type of block exists as a single instance (singleton). A world consists of thousands of references to these block instances at different positions. Consequently, a block only needs to be instantiated once during registration, and that reference is reused throughout the world.
  7. Use built-in Codecs for basic Java types

    Mojang provides built-in Codecs for common Java primitive types and their wrappers. These serve as the fundamental building blocks for creating more complex Codecs. Common examples include Codec.BOOL, Codec.INT, Codec.STRING, and Codec.FLOAT.
  8. Understand the Ingredient predicate processor

    Ingredient is a predicate processor for item-based inputs. It is used to verify whether a specific item stack meets the conditions required to be a valid input for a recipe. In the context of crafting and processing, all participating item stacks, liquids, and other inputs are collectively referred to as ingredients.
  9. Understand Minecraft DataComponents for item data storage

    DataComponents are key-value pairs used to store data on an ItemStack. Unlike generic encoding instances (such as CompoundTag or JsonElement), data components—such as firework explosions or tool properties—are stored as actual objects on the stack. This allows the values to be visible and operable without requiring dynamic conversion.
  10. Understand Minecraft Attributes and Modifiers

    Attributes are double-precision floating-point values that determine specific characteristics of entities (players, mobs, and armor stands). Each attribute consists of a base value and can have multiple modifiers. The final effective value is calculated by applying modifiers to the base value, though the result is always clamped between the attribute's hardcoded minimum and maximum values.
  11. Register a Solar Panel block with energy storage in KubeJS

    To create a solar panel, register a block using StartupEvents.registry. You must define a block entity with energy storage capabilities and a tick frequency to allow for periodic energy generation logic.
    StartupEvents.registry('block', (event) => {
        event.create('<namespace>:solar_panel', 'cardinal')
        .parentModel('<namespace>:block/solar_panel')
        .hardness(2)
        .resistance(100)
        .fullBlock(false)
        .requiresTool(false)
        .renderType('cutout')
        .box(0.1, 0, 0.1, 0.9, 0.5, 0.9, false)
        .suffocating(false)
        .viewBlocking(true)
        .blockEntity((entityInfo) => {
            // energyStorage(name, [side_filters], capacity, default_energy, max_transfer_rate, etc)
            entityInfo.energyStorage('energy', [], 2147483647, 0, 10000, 0)
            entityInfo.serverTicking()
            entityInfo.tickFrequency(20)
        });
    });
  12. Set up the development environment for KubeJS

    For KubeJS development (TS/JS), Visual Studio Code (VSC) is the recommended editor due to its strong support for these languages and the availability of specialized plugins.