DarknessLib is a library mod with functions for dealing with light calculations and built in support for the most common mods with dynamic lights. As it is a library mod, it does little by itself, but other mods can add support for it in order to reduce the need to create the same kind of code.
This library provides the following:
- Functions for checking the relative light level (which also takes things like standing in soul sand into account)
- Support for Atomic Stryker's Dynamic Lights, Optifine's Dynamic Lights and Smooth Entity Light. Functionality works on a player-to-player basis (if enabled, any player using either of the named dynamic light mods will have that light added to their total light, rather than the client saying it is bright while the server side says it isn't), and there is a configurable list you add additional handheld light sources to (if they haven't already been discovered, as the library has built in functionality to try and determine light sources out of all registered Blocks)
- A built in list of vehicles that mods relying on the library can check for prior to checking the light level (as both minecarts and boats obscure the light level when you're inside one)
- IMC support for mods to add both handheld light sources and vehicles to the respective lists within the mod (or you can open a ticket on the issue tracker with the modid and path to the vehicle entity class, and I'll include it in the internal list)
The mod also comes with a few config options:
Dynamic Lights List:
Items/Blocks added to this list will be regarded as handheld light sources while AtomicStryker's Dynamic Lights is present, or Optifine if its Dynamic Lights is enabled (and Dynamic Lights Mode is enabled), or if Smooth Entity Light is present. Most light-emitting Blocks are automatically detected as light sources, so you might not have to add them to this list (check the log as it lists all that it finds)
Format: modid:name:meta;light_level, where meta and light_level are optional (light level is automatically set to 15 if not specified).
Minecraft Restart Required!
S:"Dynamic Lights List" <
Dynamic Lights Mode:
If this is enabled (client and server), handheld light sources will be treated as actual light while AtomicStryker's Dynamic Lights is present, or Optifine if its Dynamic Lights is enabled, or Smooth Entity Light is present.
B:"Dynamic Lights Mode"=false
If you want to add vehicles from your mod to the vehicle list, you can do so with the following code:
FMLInterModComms.sendMessage("darknesslib", "addVehicle", "path.to.mod.Entity"); //or any alternative where you get the exact path
Where the path simply is the path to your vehicle Entity (be sure to check beforehand whether or not the light calculates are affected by it). If your vehicle extends the vanilla Minecart of Boat, they'll automatically get detected by the system. Naturally, if you have a lot of vehicles, you only need to register your base class for them (assuming you have one).
If you want to add handheld light sources from your mod to the dynamic lights list, you can do so with the following code:
FMLInterModComms.sendMessage("darknesslib", "addLightsource", new ItemStack(INSERT_ITEM_REFERENCE_HERE);
FMLInterModComms.sendMessage("darknesslib", "addLightsource", "modid:name:meta;light_level");
Where the ItemStack version will set the light level to 15, and the String version will default to OreDictionary.WILDCARD_VALUE if meta is omitted (and light level will be set to 15 as well if it's omitted).
This mod has built in support for:
- Vehicles from MrCrayfish's Vehicle Mod.
Mods that use this library
If you want to support the development of my mods, consider becoming a patron! You can click on the image below to visit my Patreon page.
I'm sponsored by Aim2Game, and you can use the following codes for discounts on your own server!
ABYSSAL25 - 25% off for life for new customers
ABYSSAL50 - 50% off first month for new customers
This mod may be redistributed as part of a modpack, provided proper credit to the author (me, Shinoow) is given, along with a link back to the Curse/CurseForge page for the mod. You are not allowed to redistribute the mod on third party websites (by mirroring the mod or creating a "mod installer"), and legal actions will be taken against websites found violating this.
I've set up a discord server for my mods (conveniently named "AbyssalCraft"). Click the image below to join!