Tweakable XP Loss
一个小型的服务端 NeoForge 模组,允许你配置玩家死亡后保留的经验值百分比,从而覆盖原版默认的经验值丢失机制。
玩家不需要在客户端安装此模组——它完全在服务端运行。
支持版本
该模组提供三个 jar 文件,分别针对其对应时代的 Minecraft/NeoForge API 编译。请根据你所使用的 Minecraft 版本选择对应的文件:
| Jar | Minecraft | NeoForge |
|---|---|---|
tweakable_xp_loss-<version>-mc1.21.1.jar |
1.21.1 – 1.21.10 | 21.1.x – 21.10.x |
tweakable_xp_loss-<version>-mc1.21.11.jar |
1.21.11 | 21.11.x |
tweakable_xp_loss-<version>-mc26.2.jar |
26.2 | 26.2.x-beta |
26.2 版本的 jar 以**测试版(beta)**形式发布:Minecraft 26.2 是一个稳定版本,但截至撰写本文时,NeoForge for 26.2 本身仍处于仅 beta 状态(尚无稳定的 26.2.x 构建)。该模组在 26.x 上的 GameRules API 与 1.21.11 完全相同,因此模组代码未作更改——仅编译目标和 Java 工具链(25 vs 21)不同。一旦 NeoForge 26.2 发布了稳定构建,它将转为正式版。
为什么需要多个 jar? Minecraft 1.21.11 重构了
GameRulesAPI(keepInventory游戏规则的包路径、类型和访问器均发生了变化),而 MC 26.x 在此基础上又是一个全新的主版本。与其依赖运行时反射,每个 jar 都直接调用其对应时代的 API——经过编译检查且逻辑清晰正确。参见docs/PORTING.md。
配置文件
首次启动时,模组会创建 config/tweakable_xp_loss-common.toml:
#主开关。如果为 false,模组不执行任何操作(使用纯原版经验值丢失机制)。
enabled = true
#玩家通过死亡保留的经验值百分比(0-100)。
# 100 = 保留所有 XP(无丢失)。
# 0 = 原版行为(丢失所有 XP)。
# 范围:0 ~ 100
keepPercentage = 100
#保留的经验值返还给玩家的方式:
# INSTANT = 重生时直接授予玩家(无掉落物球)。
# ORBS = 在死亡位置作为经验球掉落(可回收;墓碑/尸体模组可能会收集它们)。
#允许的值:INSTANT, ORBS
awardMethod = "INSTANT"
编辑文件并运行 /reload(或重启服务器)以应用更改。
“keepPercentage”的含义
它是玩家总累积经验值(等级条背后的原始 XP 数值)的百分比,而不是等级的百分比。例如,keepPercentage = 50 意味着玩家重生时将拥有死亡前一半的经验值点数。
工作原理(底层机制)
- 当玩家死亡时,原版通常会在死亡地点散落少量经验值作为经验球(
min(level * 7, 100)点),并在重生时将玩家的 XP 重置为 0。 - 本模组:
- 抑制那部分原版经验球的掉落(通过
LivingExperienceDropEvent),以防止保留的经验值被重复计算,仅在激活状态下生效; - 将保留的部分要么直接在重生时返回(
INSTANT,通过PlayerEvent.Clone),要么作为经验球在死亡位置返回(ORBS,通过LivingDeathEvent)。
- 抑制那部分原版经验球的掉落(通过
与其他死亡模组的兼容性(CorPse、墓碑等)
- 此模组从不触碰物品掉落,因此与仅处理物品的尸体/墓碑模组开箱即用完全兼容。
- 当
keepPercentage = 0(或enabled = false)时,此模组完全不执行任何操作,原版行为得到完全保留,因此任何其他模组的 XP 处理都不会受到影响。 - 如果你使用了一个管理死亡经验值的模组(它将你的完整 XP 存储在坟墓中,稍后退还),请将
keepPercentage = 0设置为避免此模组重复发放经验值。
注意事项
- 当启用
keepInventory游戏规则时,该模组为无效操作(no-op),因为此时原版已经保留了 XP。 - 构建版本不包含任何客户端代码;将构建好的 jar 放入服务器的
mods/文件夹即可。
构建
为特定时代构建 jar(默认为 legacy):
./gradlew build # legacy jar -> build/libs/tweakable_xp_loss-<ver>-mc1.21.1.jar
./gradlew build -Pera=modern # modern jar -> build/libs/tweakable_xp_loss-<ver>-mc1.21.11.jar
./gradlew build -Pera=next # next jar -> build/libs/tweakable_xp_loss-<ver>-mc26.2.jar (Java 25)
1.21.x 时代需要 Java 21,26.x 时代需要 Java 25;如果未安装所需的工具链,Gradle 会自动下载。
持续集成与发布
build工作流 (.github/workflows/ci.yml) 在每次推送/PR 时针对每个目标 Minecraft/NeoForge 版本编译模组——跨小版本的作业充当 API 漂移的触发器。release工作流 (.github/workflows/release.yml) 在v*git 标签触发时运行:它构建所有三个 jar 文件,并通过 Minotaur 将它们分别发布为 Modrinth 上的独立版本(项目 slug 为tweakable-xp-loss),并将它们附加到 GitHub Release 中。 需要MODRINTH_TOKEN仓库密钥以及一个已存在的 Modrinth 项目。
Tweakable XP Loss
A small server-side NeoForge mod that lets you configure the percentage of experience points a player keeps after death, overriding the default vanilla XP loss.
Players do not need this mod installed on their client — it runs entirely on the server.
Supported versions
The mod ships as three jars, each compiled against its era's Minecraft/NeoForge APIs. Pick the one that covers your Minecraft version:
| Jar | Minecraft | NeoForge |
|---|---|---|
tweakable_xp_loss-<version>-mc1.21.1.jar |
1.21.1 – 1.21.10 | 21.1.x – 21.10.x |
tweakable_xp_loss-<version>-mc1.21.11.jar |
1.21.11 | 21.11.x |
tweakable_xp_loss-<version>-mc26.2.jar |
26.2 | 26.2.x-beta |
The 26.2 jar is published as a beta version: Minecraft 26.2 is a stable release, but NeoForge for 26.2 is itself still beta-only at the time of writing (no stable 26.2.x build yet). The mod's GameRules API on 26.x is identical to 1.21.11's, so the mod code is unchanged — only the compile target and Java toolchain (25 vs 21) differ. It will flip to a release version once NeoForge 26.2 ships a stable build.
Why multiple jars? Minecraft 1.21.11 restructured the
GameRulesAPI (thekeepInventorygamerule moved package, changed type, and changed its accessor), and MC 26.x is a new major on top of that. Rather than rely on runtime reflection, each jar calls its era's API directly — compile-checked and obviously correct. Seedocs/PORTING.md.
Config
On first launch the mod creates config/tweakable_xp_loss-common.toml:
#Master switch. If false, the mod does nothing (pure vanilla XP loss).
enabled = true
#Percentage of experience points a player keeps through death (0-100).
# 100 = keep all XP (no loss).
# 0 = vanilla behavior (lose all XP).
# Range: 0 ~ 100
keepPercentage = 100
#How the kept XP is returned to the player:
# INSTANT = granted directly to the player on respawn (no orbs).
# ORBS = dropped as experience orbs at the death location (recoverable; gravestone/corpse mods may collect them).
#Allowed Values: INSTANT, ORBS
awardMethod = "INSTANT"
Edit the file and run /reload (or restart the server) to apply changes.
What "keepPercentage" means
It is a percentage of the player's total accumulated experience points (the raw XP behind the levels bar),
not a percentage of levels. For example, keepPercentage = 50 means a player respawns with half of the XP
points they had before dying.
How it works (under the hood)
- When a player dies, vanilla normally scatters a small amount of XP as orbs at the death point
(
min(level * 7, 100)points) and resets the player's XP to 0 on respawn. - This mod:
- suppresses that small vanilla orb drop (via
LivingExperienceDropEvent) so retained XP isn't double-counted, only when active; - returns the retained portion either directly on respawn (
INSTANT, viaPlayerEvent.Clone) or as orbs at the death location (ORBS, viaLivingDeathEvent).
- suppresses that small vanilla orb drop (via
Compatibility with other death mods (CorPse, gravestones, …)
- This mod never touches item drops, so it is fully compatible out-of-the-box with corpse/gravestone mods that only handle items.
- When
keepPercentage = 0(orenabled = false), this mod performs no work at all and vanilla behavior is fully preserved, so any other mod's XP handling is untouched. - If you use a mod that manages experience on death (it stores your full XP in a grave and refunds it
later), set
keepPercentage = 0to avoid this mod double-awarding XP.
Notes
- The mod is a no-op when the
keepInventorygamerule is enabled (vanilla already preserves XP then). - Builds with no client-side code; drop the built jar into the server's
mods/folder.
Building
Build the jar for a specific era (defaults to legacy):
./gradlew build # legacy jar -> build/libs/tweakable_xp_loss-<ver>-mc1.21.1.jar
./gradlew build -Pera=modern # modern jar -> build/libs/tweakable_xp_loss-<ver>-mc1.21.11.jar
./gradlew build -Pera=next # next jar -> build/libs/tweakable_xp_loss-<ver>-mc26.2.jar (Java 25)
Java 21 is required for the 1.21.x eras and Java 25 for the 26.x era; Gradle auto-downloads the needed toolchain if it is not installed.
Continuous integration & publishing
buildworkflow (.github/workflows/ci.yml) compiles the mod against every targeted Minecraft/NeoForge version on each push/PR — the cross-minor jobs act as a tripwire for API drift.releaseworkflow (.github/workflows/release.yml) triggers on av*git tag: it builds all three jars, publishes each as a separate Modrinth version (via Minotaur), and attaches them to a GitHub Release. Requires aMODRINTH_TOKENrepository secret and an existing Modrinth project (slugtweakable-xp-loss).
下载 tweakable-xp-loss
下载 tweakable-xp-loss
下载 tweakable-xp-loss
下载 tweakable-xp-loss
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 tweakable-xp-loss
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 tweakable-xp-loss
下载 tweakable-xp-loss
下载 tweakable-xp-loss
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
下载 tweakable-xp-loss
下载 tweakable-xp-loss
需要联机服务器吗?
稳定流畅、一键部署,几分钟即可和朋友联机开服
最低仅需 8 元/月 即可畅快联机
更新日志
Tweakable XP Loss 的所有重要更改都将记录在此文件中。
格式遵循 Keep a Changelog,本项目 采用 语义化版本控制(每个发布制品在每个 Minecraft 时代分类后带有后缀)。
[1.2.0] - 2026-07-16
新增
- Minecraft 26.2 支持(第三个 jar 包)。
tweakable_xp_loss-1.2.0-mc26.2.jar通过 NeoForge26.2.x-beta针对 Minecraft 26.2,并使用 Java 25 工具链编译。由于 NeoForge for 26.2 本身仍处于仅限 beta 阶段(尽管 Minecraft 26.2 是稳定版),因此作为 beta Modrinth 版本发布。GameRules API 在 26.x 上与 1.21.11 相同,因此模组代码未作更改——仅编译目标和 Java 工具链不同。已验证:可针对 26.2.0.23-beta 编译并启动 26.2 服务器。
更改
- 构建的 Java 工具链现在按时代驱动:
legacy/modern时代使用 Java 21,新的next时代(MC 26.x)使用 Java 25。Gradle 会自动配置所需的 JDK。 - CI 和发布工作流现在会构建并发布所有三个时代(legacy、modern、next)。发布工作流会安装 Java 21 和 25。
mod_version从1.1.0提升至1.2.0。
备注
- MC 26.1(拥有稳定版 NeoForge,不同于 26.2)尚未成为独立目标,但这是一个简单的后续步骤——源代码与 26.2 jar 包完全相同;仅需更改 NeoForge 编译版本和游戏版本列表即可。参见
docs/PORTING.md。
[1.1.0] - 2026-07-15
新增
- 多版本支持。 该模组现在提供两个 jar 包,分别针对其所属时代的直接 GameRules API 进行编译:
tweakable_xp_loss-1.1.0-mc1.21.1.jar— Minecraft 1.21.1–1.21.10(NeoForge 21.1.x–21.10.x)。tweakable_xp_loss-1.1.0-mc1.21.11.jar— Minecraft 1.21.11(NeoForge 21.11.x)。 请选择覆盖您 Minecraft 版本的 jar 包。详情请参阅 README。
- 版本元数据(
mods.toml)现在声明了正确的各时代 Minecraft 和 NeoForge 范围。
更改
mod_version从1.0.0提升至1.1.0。- keep-inventory 游戏规则的读取以及
ServerLevel访问器被提取为特定于时代的KeepInventoryCompat接口层,使得共享的死亡/重生逻辑在这两个 jar 包中保持一致。这是多版本计划中的“方案 C”(见docs/PORTING.md)。 - legacy 接口层通过
((ServerLevel) player.level()).getGameRules()而非player.level().getGameRules()读取游戏规则:getGameRules()在 1.21.2/1.21.3 边界处从Level移至ServerLevel,因此在ServerLevel上调用它才能使一个 legacy jar 包在 1.21.1–1.21.10 范围内保持二进制兼容。CI 的触发器矩阵会在每次推送到仓库时针对 1.21.3/1.21.4/1.21.5/1.21.8/1.21.10 重新编译 legacy 源代码以保护这一点。
备注
- Minecraft 26.x(NeoForge 26.x)尚未针对——它仍处于 beta 阶段且需要 Java 25。其 GameRules API 与 1.21.11 相同,因此一旦 26.x 进入稳定期,添加第三个 jar 包或扩大现代 jar 包的范围将非常简单。
[1.0.0] - 初始发布
- 面向 Minecraft 1.21.1 的服务端 NeoForge 模组:可配置死亡时保留的经验值百分比,可在重生时立即给予(
INSTANT)或在死亡位置生成经验球(ORBS)。文件配置文件位于config/tweakable_xp_loss-common.toml。
关于这个资源的讨论、问题反馈与使用心得
还没有讨论,来发第一帖吧
你是这个资源的作者?登录后可认领此资源。
相似资源
模组
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
模组
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
模组
查看物品与配方
模组
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
模组
AE2:一款流行的自动化与存储模组
模组
那是什么?一个 Waila/Hwyla 的分支。
评论 0
登录后参与评分
还没有评论,来抢沙发吧