跳到正文

LightAPI

作者:MisterBartra

High-performance dynamic lighting engine and spatial indexing API for Minecraft Fabric 1.21.11+. Features volumetric shapes, double-buffered bake pipeline, and multi-light grouping.

收藏

介绍

中文介绍正在准备中,下面暂时显示原文。

💡 LightAPI

Fabric
Minecraft
Java
Dependency

LightAPI is a next-generation dynamic lighting framework and spatial registry created for modern Minecraft (1.21.11+). Built to bridge the gap following Mojang’s extensive GPU and vertex consumer pipeline overhaul (OrderedRenderCommandQueue, ModelCommandRenderer), LightAPI provides a resilient, clean, and thread-safe abstraction for registering, updating, and querying dynamic light sources in the world.


🚀 Key Features

  • 🌐 3D Spatial Partitioning:
    • Chunk-based spatial hashing (CellHasher, SpatialIndex) for \(O(1)\) spatial queries near players and cameras.
  • 🛡️ Thread-Safe Double Buffering (LightBaker):
    • Staged write-buffers and atomic snapshot swapping (LightSnapshot) ensure asynchronous light queries never cause concurrency locks or frame drops on the render thread.
  • 📐 Geometric Shapes & Volumetric Lighting:
    • Supports multiple volumetric emitters: SPHERE, VOLUME_BOX, CAPSULE, EDGE_CURVE, PLANE, ELLIPSE, and CONE.
    • Physics-based attenuation curves: LINEAR, QUADRATIC, and SMOOTH falloff.
  • 👥 Multi-Light Grouping (LightGroupManager):
    • Contiguous light fixtures (such as modular neon strips or linked light bars) automatically merge into unified volumetric groups, dramatically reducing GPU overhead.
  • 🔄 Decoupled Chromatic Math:
    • Modular Dual-Mode Architecture:
    • Standalone Mode: Zero external color dependencies. Operates as a pure vanilla lighting engine with 0–15 photometric scalar falloff.
    • Chromatic Mode: Dynamically detects ColorAPI via Fabric Loader / SPI (IColorEngineBridge) to unlock full multi-channel RGB/HSV spectral propagation without static bytecode coupling.

💻 Developer Quick Start

Add LightAPI to your build.gradle:

repositories {
    mavenCentral()
    mavenLocal()
}

dependencies {
    modImplementation "mb.bartra:colorapi:1.0"
    modImplementation "mb.bartra:lightapi:1.0"
}

Registering a Dynamic Light Source:

import mb.bartra.lightapi.LightAPI;
import mb.bartra.lightapi.core.LightRegistration;
import mb.bartra.lightapi.core.LightHandle;
import mb.bartra.lightapi.core.CompositeLightShape;
import mb.bartra.lightapi.engine.TickMode;
import net.minecraft.util.math.BlockPos;

// 1. Quick Registration
LightHandle handle = LightAPI.registerLight(pos, 15.0f, 0xFF5500);

// 2. Advanced Volumetric Registration
LightRegistration reg = new LightRegistration(pos, 15.0f, 0x00FF88)
    .compositeShape(CompositeLightShape.VOLUME_BOX)
    .tickMode(TickMode.REAL_TIME);

LightHandle advancedHandle = LightAPI.registerLight(reg);

// 3. Remove when done
LightAPI.removeLight(handle);

🧩 Dependencies

  • Fabric API (Required)
  • ColorAPI (Optional / Soft Dependency — enables multi-channel RGB chromatic lighting; operates in standalone monochrome mode if absent)

📄 License

MIT License. Free to use in any CurseForge or Modrinth modpack.

常见问题

LightAPI 支持哪些 Minecraft 版本?

LightAPI 支持 Minecraft Java 版 1.21.11,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

LightAPI 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。

评论

登录后评论和评分

MisterBartra 的其他作品

查看全部 →