Drop Stacker
一个用于 Minecraft 的 Fabric 模组,可自动将地面上掉落的物品实体堆叠为单个实体,从而减少实体卡顿并保持世界整洁。
功能特性
- 即时合并: 新掉落的物品在生成的瞬间就会被吸收进附近的堆中——在同一刻完成,而非等待扫描间隔。怪物的掉落物在你看到它们落地之前就已经坍缩合并了。
- 整堆坍缩: 每次合并操作会一次性排干所有兼容的相邻堆,因此一个包含 100 个物品的堆会在单次操作中变为一个实体,而不是一次只合并一个物品。
- 无限堆叠: 支持超出原版 64 个物品的上限——最多可达你配置的
maxStackSize,并支持针对单个物品的覆盖设置。
- 视觉反馈: 在物品上方显示彩色的堆数量标签(阈值可配置)。
- 消失计时器: 标签上可选地显示倒计时,并根据紧迫感进行颜色编码(支持使用
∞ 表示无限物品)。
- 自适应扫描: 闲置的堆会逐渐降低扫描频率(最高至
maxScanInterval),因此满是静止物品的世界几乎不消耗性能。这是安全的,因为新掉落物会在生成时推入堆中,而不是等待被轮询。
- 物品规则: 黑名单、白名单以及针对单个物品的堆叠大小覆盖——均接受物品标签(如
#minecraft:logs)以及精确 ID。
- 运行时控制:
/dropstacker 命令可在不重启的情况下重载配置文件、报告统计信息并调整设置。
- 尊重命名物品: 拥有自定义名称的物品实体永远不会被重新标记或无声地吸收到其他堆中。
- 原版兼容性: 合并操作遵循原版的无限寿命、临近消失和无限拾取延迟保护机制,并保留最长的拾取延迟,以确保合并不会缩短它。
- 仅服务端运行: 所有逻辑均在服务器端执行。未安装模组的原版客户端也能看到数量和计时器。
依赖要求
命令
/dropstacker 需要权限等级 2(管理员)。
| 命令 |
描述 |
/dropstacker reload |
从磁盘重载配置文件 |
/dropstacker stats |
查看合并次数、坍缩的实体数及当前设置 |
/dropstacker resetstats |
重置计数器 |
/dropstacker toggle |
在运行时启用/禁用堆叠功能 |
/dropstacker set maxStackSize <n> |
更改堆叠上限 |
/dropstacker set scanInterval <n> |
更改扫描间隔 |
/dropstacker set radius <n> |
更改水平扫描半径 |
/dropstacker set verticalRadius <n> |
更改垂直扫描半径 |
配置
配置文件会自动创建在 .minecraft/config/drop-stacker.json(服务器端则为 config/drop-stacker.json)。如果你升级模组,字段会在重启时自动更新。
{
"enabled": true,
"mergeOnSpawn": true,
"maxStackSize": 1000,
"radius": 5.0,
"verticalRadius": 2.0,
"scanInterval": 5,
"maxScanInterval": 100,
"maxMergePerPass": 64,
"ageInheritance": "YOUNGEST",
"labelMode": "ALWAYS",
"showDespawnTimer": true,
"countLowThreshold": 64,
"countHighThreshold": 500,
"hideSingleItemLabel": false,
"despawnTicks": 6000,
"blacklist": [],
"whitelist": [],
"overrides": {}
}
| 字段 |
描述 |
默认值 |
enabled |
所有堆叠功能的总开关 |
true |
mergeOnSpawn |
新掉落物生成时立即合并 |
true |
maxStackSize |
每个堆叠实体的最大物品数量 |
1000 |
radius |
水平扫描半径(方块) |
5.0 |
verticalRadius |
垂直扫描半径(方块) |
2.0 |
scanInterval |
活跃堆之间合并扫描的间隔刻度 |
5 |
maxScanInterval |
闲置堆退避到的最慢扫描速率 |
100 |
maxMergePerPass |
单次操作中吸收的最大相邻堆数量 |
64 |
ageInheritance |
合并时的消失计时器继承策略:YOUNGEST(最年轻)、KEEP_RECEIVER(保持接收者)或 OLDEST(最古老) |
YOUNGEST |
labelMode |
何时显示标签:ALWAYS(始终)、STACKED_ONLY(仅堆叠时)或 NEVER(从不) |
ALWAYS |
showDespawnTimer |
在标签上显示消失倒计时 |
true |
countLowThreshold |
标签变黄的计数阈值 |
64 |
countHighThreshold |
标签变红的计数阈值 |
500 |
hideSingleItemLabel |
如果堆中只有一个物品,则隐藏标签 |
false |
despawnTicks |
世界消失速率(与服务器设置的计时器匹配) |
6000 |
blacklist |
永不堆叠的物品列表 |
[] |
whitelist |
若非空,仅堆叠这些物品 |
[] |
overrides |
针对单个物品的堆叠上限 |
{} |
物品规则
blacklist、whitelist 和 overrides 均接受精确物品 ID 和物品标签(以 # 开头):
{
"blacklist": ["minecraft:elytra", "#minecraft:shulker_boxes"],
"overrides": {
"minecraft:cobblestone": 5000,
"#minecraft:logs": 512
}
}
关于 ageInheritance 的说明
默认的 YOUNGEST 意味着当堆吸收掉落物时,它会继承剩余寿命最长的那个——因此农场旁边的堆会不断重置其消失计时器,实际上永远不会消失。这很方便,但在繁忙的服务器上,这会导致物品堆无限累积。如需原版消失行为,请设置为 KEEP_RECEIVER。
构建
./gradlew build
输出的 JAR 文件位于 build/libs/ 目录中。Gradle 会自动提供所需的 Java 25 工具链。
许可证
MIT — 见 LICENSE。
[!CAUTION]
我不擅长 Kotlin,该项目是在 AI 协助下构建的。可能存在糟糕的代码、错误的模式或可以做得更好的地方。如果你发现任何问题——请提交 Issue 或 Pull Request。我真诚地感谢你的贡献,并将从中学习。谢谢。
Drop Stacker
A Fabric mod for Minecraft that automatically stacks dropped item entities on the ground into a single entity, reducing entity lag and keeping your world tidy.
Features
- Instant Merging: New drops are absorbed into a nearby pile the moment they spawn — in the same tick, not after a scan interval. A mob's drops collapse before you see them land.
- Whole-Pile Collapse: Each merge pass drains every compatible neighbour at once, so a 100-item pile becomes one entity in a single pass instead of one item per pass.
- Limitless Piles: Stacks beyond vanilla's 64-item limit — up to your configured
maxStackSize, with per-item overrides.
- Visual Feedback: Colorful stack count label displayed above items (configurable thresholds).
- Despawn Timer: Optional countdown on the label with urgency-based color coding (supports infinite items with
∞).
- Adaptive Scanning: Idle piles progressively back off from scanning (up to
maxScanInterval), so a world full of settled items costs almost nothing. Safe because new drops push into piles on spawn rather than waiting to be polled.
- Item Rules: Blacklist, whitelist, and per-item stack-size overrides — all accepting item tags (
#minecraft:logs) as well as exact ids.
- Runtime Control:
/dropstacker reloads config, reports stats, and tunes settings without a restart.
- Respects Named Items: An item entity with its own custom name is never relabelled or silently absorbed into another pile.
- Vanilla Parity: Merging honours vanilla's infinite-lifetime, near-despawn, and infinite-pickup-delay guards, and keeps the longest pickup delay so merging can't shorten it.
- Server-Side Only: All logic runs on the server. Vanilla clients see counts and timers with no mod installed.
Requirements
Commands
/dropstacker requires permission level 2 (gamemasters).
| Command |
Description |
/dropstacker reload |
Reload the config file from disk |
/dropstacker stats |
Merge passes, entities collapsed, and current settings |
/dropstacker resetstats |
Reset the counters |
/dropstacker toggle |
Enable/disable stacking at runtime |
/dropstacker set maxStackSize <n> |
Change the stack cap |
/dropstacker set scanInterval <n> |
Change the scan interval |
/dropstacker set radius <n> |
Change the horizontal scan radius |
/dropstacker set verticalRadius <n> |
Change the vertical scan radius |
Configuration
The config file is created automatically at .minecraft/config/drop-stacker.json (or config/drop-stacker.json on a server). Fields update automatically on restart if you upgrade the mod.
{
"enabled": true,
"mergeOnSpawn": true,
"maxStackSize": 1000,
"radius": 5.0,
"verticalRadius": 2.0,
"scanInterval": 5,
"maxScanInterval": 100,
"maxMergePerPass": 64,
"ageInheritance": "YOUNGEST",
"labelMode": "ALWAYS",
"showDespawnTimer": true,
"countLowThreshold": 64,
"countHighThreshold": 500,
"hideSingleItemLabel": false,
"despawnTicks": 6000,
"blacklist": [],
"whitelist": [],
"overrides": {}
}
| Field |
Description |
Default |
enabled |
Master switch for all stacking |
true |
mergeOnSpawn |
Merge new drops instantly as they spawn |
true |
maxStackSize |
Maximum items per stacked entity |
1000 |
radius |
Horizontal scan radius (blocks) |
5.0 |
verticalRadius |
Vertical scan radius (blocks) |
2.0 |
scanInterval |
Ticks between merge scans for an active pile |
5 |
maxScanInterval |
Slowest scan rate an idle pile backs off to |
100 |
maxMergePerPass |
Max neighbours absorbed in one pass |
64 |
ageInheritance |
Despawn timer on merge: YOUNGEST, KEEP_RECEIVER, or OLDEST |
YOUNGEST |
labelMode |
When to show the label: ALWAYS, STACKED_ONLY, or NEVER |
ALWAYS |
showDespawnTimer |
Show despawn countdown on the label |
true |
countLowThreshold |
Count at which the label turns Yellow |
64 |
countHighThreshold |
Count at which the label turns Red |
500 |
hideSingleItemLabel |
Hide the label if the stack only has 1 item |
false |
despawnTicks |
World despawn rate (matches timer to server settings) |
6000 |
blacklist |
Items that are never stacked |
[] |
whitelist |
If non-empty, only these items are stacked |
[] |
overrides |
Per-item stack caps |
{} |
Item rules
blacklist, whitelist, and overrides all accept exact item ids and item tags (prefixed with #):
{
"blacklist": ["minecraft:elytra", "#minecraft:shulker_boxes"],
"overrides": {
"minecraft:cobblestone": 5000,
"#minecraft:logs": 512
}
}
A note on ageInheritance
The default YOUNGEST means a pile inherits the longest remaining lifetime when it absorbs a drop — so a pile next to a farm keeps resetting its despawn timer and effectively never despawns. That is convenient, but on a busy server it lets item piles accumulate indefinitely. Set KEEP_RECEIVER for vanilla despawn behaviour.
Building
./gradlew build
Output JAR is in build/libs/. Gradle provisions the required Java 25 toolchain automatically.
License
MIT — see LICENSE.
[!CAUTION]
I am not great at Kotlin and this project was built with AI assistance. There may be bad code, wrong patterns, or things that could be done much better. If you spot anything — please open an issue or a pull request. I genuinely appreciate it and will learn from it. Thank you.
评论 0
登录后参与评分
还没有评论,来抢沙发吧