Download Luminance Block Entities - Fabric — Minecraft Mods — MetaMods

Luminance Block Entities - Fabric

Active

Downloads

0

Last update

4 years ago
Client
Libraries
Technological

Luminance Block Entities - Fabric

This API enables block entities (such as chests, furnaces, dispensers, and others) to emit light in the Minecraft world, similar to glowstone blocks or redstone lamps. However, unlike them, this utility completely bypasses the use of block states. This makes it an ideal solution for mods that want to add new blocks with multiple states that can also emit light, or for projects requiring fine control over lighting. WORKS ONLY WITH FABRIC

For Players

If another mod requires this API as a dependency, simply download it here and place it in the mods folder along with your other mods.

For Developers

Setup

To use this API in your mods, download the JAR file and place it in your Fabric development environment. In the build.gradle file, add:

flatDir {
    dirs 'path/to/folder/with/JAR' // Specify the path to the folder with the JAR file
}

to the repositories section. Then add:

modImplementation "com.nonumberstudios.luminance_block_entities:luminance_block_entities:1.0.0" // Replace the version with the current one

to the dependencies section.

Usage

After setup, you can create block entities as usual via Fabric. Instead of inheriting from BlockEntity, your class should inherit from LuminanceBlockEntity provided by the API. This class requires a LuminanceBehavior parameter - an enumeration that determines how to use lighting from the block entity or block state:

  • IGNORE: use only lighting from the block entity, ignoring the block state. This is probably what you need.
  • FALLBACK: use lighting from the block entity if it exists. If lighting is zero, use the block state as a fallback.
  • PRIORITY: use lighting from the block state if it exists. If lighting is zero, use the block entity as a fallback.

Next, you need to implement the getLuminance method. You can do whatever you want in it. To update the world's lighting according to the returned value of getLuminance, call the updateLuminance method defined in LuminanceBlockEntity. Call it only if the lighting has actually changed! This operation is quite resource-intensive.

During mod initialization, you can call LuminanceBlockEntitiesMod.initializeExample() to load an example block entity into the game. This is a simple block (without textures, etc.) that can be found in the "Miscellaneous" tab. When placed, it generates a random lighting value from 0 to 15 each tick and updates the world lighting accordingly (see video below). Theoretically, changing the block state every tick in the vanilla style would be more costly, but you can find better applications for this API. You can study the GlowBlockEntity class to see the implementation.

Example implementation:

Project members
NoNumberMan

NoNumberMan

Created: 9 Feb 2022

ID: 37377