概述
DarknessLib 是一个库模组,提供了处理光照计算的功能,并内置了对大多数常见动态光照模组的支持。作为库模组,它本身的功能有限,但其他模组可以通过添加对其支持来减少重复编写同类代码的需求。
功能
该库提供以下功能:
- 用于检查相对光照等级的函数(这也考虑了站在灵魂沙上等特殊情况)
- 支持 Atomic Stryker's Dynamic Lights、Optifine's Dynamic Lights 和 Smooth Entity Light。功能基于玩家之间的工作方式(如果启用,任何使用上述任一动态光照模组的玩家都会将其光源计入总光照中,而不是客户端显示明亮而服务器端显示不亮),并且有一个可配置的列表,你可以向其添加额外的手持光源(如果尚未被自动发现,因为库内置了尝试从所有已注册方块中检测光源的功能)
- 一个内置的载具列表,依赖此库的模组可以在检查光照等级之前先检查玩家是否处于这些载具中(因为矿车和船在内部时会遮挡光照等级)
- 支持通过 IMC 让模组将手持光源和载具添加到各自的列表中(或者你也可以在问题追踪器上提交工单,提供模组 ID 和载具实体类路径,我会将其包含到内部列表中)
配置
该模组还附带了一些配置选项:
动态光照列表:
添加到列表中的物品/方塊将被视为手持光源,前提是存在 AtomicStryker's Dynamic Lights,或者 Optifine 的动态光照已启用(且动态光照模式已启用),或者存在 Smooth Entity Light。大多数发光方块会被自动检测为光源,因此你可能不需要将它们添加到此列表中(请查看日志,其中列出了所有找到的光源)
格式:modid:name:meta;light_level,其中 meta 和 light_level 是可选的(如果不指定,光照等级默认设置为 15)。
需要重启 Minecraft!
S:"Dynamic Lights List" <
>
动态光照模式:
如果启用此项(客户端和服务器端),当存在 AtomicStryker's Dynamic Lights,或者 Optifine 的动态光照已启用,或者存在 Smooth Entity Light 时,手持光源将被视为实际光源。
B:"Dynamic Lights Mode"=false
IMC
如果你想将来自你模组的载具添加到载具列表中,可以使用以下代码:
FMLInterModComms.sendMessage("darknesslib", "addVehicle", "path.to.mod.Entity"); // 或者获取精确路径的任何替代方法
其中路径只是你的载具实体的路径(请务必事先检查光照计算是否会受到影响)。如果你的载具继承自原版矿车或船,它们将被系统自动检测。当然,如果你有大量载具,只需注册它们的基类即可(假设你有这样一个基类)。
如果你想将来自你模组的手持光源添加到动态光照列表中,可以使用以下代码:
FMLInterModComms.sendMessage("darknesslib", "addLightsource", new ItemStack(INSERT_ITEM_REFERENCE_HERE));
FMLInterModComms.sendMessage("darknesslib", "addLightsource", "modid:name:meta;light_level");
其中 ItemStack 版本会将光照等级设置为 15,而 String 版本如果省略 meta 则默认为 OreDictionary.WILDCARD_VALUE(如果省略光照等级,也会设置为 15)。
模组支持
本模组内置支持:
使用该库的模组
Grue(截至 1.6.0 版本)
Hungering Darkness(截至 1.3.0 版本)
捐赠
如果你想支持我的模组开发,可以考虑成为我的赞助者!你可以点击下面的图片访问我的 Patreon 页面。
服务器托管

由 Aim2Game 赞助,您可以使用以下代码在您的服务器上享受折扣!
ABYSSAL25 - 新客户终身 25% 折扣
ABYSSAL50 - 新客户首月 50% 折扣
整合包
本模组可以作为整合包的一部分进行再分发,但必须正确署名作者(我,Shinoow),并提供指向该模组 Curse/CurseForge 页面的链接。您不得在第三方网站上再分发该模组(通过镜像模组或创建“模组安装器”),对于违反此规定的网站将采取法律行动。
Discord
我为我的模组建立了一个 Discord 服务器(方便地命名为 "AbyssalCraft")。点击下方图片加入!
Overview
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.
Features
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)
Configuration
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
IMC
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).
Mod support
This mod has built in support for:
Mods that use this library
Grue (as of version 1.6.0)
Hungering Darkness (as of version 1.3.0)
Donating
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.
Server hosting

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
Modpacks
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.
Discord
I've set up a discord server for my mods (conveniently named "AbyssalCraft"). Click the image below to join!
评论 0
登录后参与评分
还没有评论,来抢沙发吧