物品上限
适用于 Minecraft Java 26.3 的可配置玩家物品上限。
限制玩家可携带的任何物品的数量,例如 1 个不死图腾或 4 个附魔金苹果。当玩家达到上限并拾取更多物品时,超出的物品会掉落在地面上。
数据包默认为空:在你使用简单的 /function 命令添加限制之前,没有任何物品会被限制。无需配置文件、无需重启、也无需 /reload。
功能特性
- 适用于任何物品(原版物品 ID)
- 在游戏中添加、更改、移除和列出限制
- 超出部分以掉落方式处理,绝不会删除(仅在掉落物成功生成后,物品才会从背包中移除)
- 统计整个玩家背包:快捷栏、主背包、护甲槽和副手
- 还统计玩家携带的潜影盒和绑束中的物品(包括潜影盒内的绑束),因此无法通过容器绕过限制
- 可选聊天消息,告知玩家物品被掉落的原因
- 豁免标签,用于不受限制的玩家(例如管理员)
- 仅服务器端运行,无需模组或资源包
- 非常轻量级:每 5 刻钟运行一次,在未配置任何限制时无操作
安装
- 下载
ItemLimits-1.1.0-mc26.3.zip。
- 将 zip 文件放入服务器的
world/datapacks/ 目录中(或在单人游戏中放入世界的 datapacks 文件夹)。
- 运行
/reload 或重启服务器。
需要 Minecraft Java Edition 26.3(数据包格式 121)。
命令
所有命令都需要操作员权限(权限等级 2,与任何 /function 相同)。
| 命令 |
作用 |
/function item_limits:add {item:"minecraft:totem_of_undying",max:1} |
添加限制,如果该物品已存在限制则进行更改 |
/function item_limits:remove {item:"minecraft:totem_of_undying"} |
移除某物品的限制 |
/function item_limits:list |
显示所有已配置的限制 |
/function item_limits:clear_all |
移除所有限制 |
/function item_limits:messages_on |
当额外物品被掉落时告知玩家(默认开启) |
/function item_limits:messages_off |
不发送这些消息 |
/function item_limits:containers_on |
统计潜影盒和绑束中的物品(默认开启) |
/function item_limits:containers_off |
仅统计散落的物品(v1.0 行为) |
示例
# 每位玩家最多 1 个图腾
/function item_limits:add {item:"minecraft:totem_of_undying",max:1}
# 每位玩家最多 4 个附魔金苹果
/function item_limits:add {item:"minecraft:enchanted_golden_apple",max:4}
# 将图腾限制更改为 2
/function item_limits:add {item:"minecraft:totem_of_undying",max:2}
# 再次移除图腾限制
/function item_limits:remove {item:"minecraft:totem_of_undying"}
提示:item 值是常规物品 ID。在游戏中按 F3 + H 可在物品工具提示中查看 ID。max:0 完全禁止该物品(所有物品都会被掉落)。
豁免玩家
/tag <player> add item_limits.bypass
/tag <player> remove item_limits.bypass
工作原理
每 5 刻钟,系统会检查每位玩家是否违反任何已配置的限制。总数等于散落的物品加上玩家携带的所有潜影盒和绑束中的物品。如果玩家携带的数量超过允许值,超出部分会在其脚下掉落(带有 5 秒的拾取延迟)。先掉落散落物品(通常是刚刚拾取的物品)。如果超出部分位于潜影盒或绑束中,则将其从容器中取出,容器仍保留在原背包槽位中,并将其原始组件作为掉落物处理。如果玩家严重超出限制(例如因为你刚刚添加了限制),每次检查最多处理 64 个物品,直到数量符合限制为止。
限制存储在 item_limits:config 命令存储中,因此它们随世界保存,并在重启和 /reload 后保留。
局限性
- 计入统计: 玩家的背包、副手、护甲槽,以及其中的潜影盒和绑束的内容(包括潜影盒内的绑束)。不计入统计: 末影箱、世界中的箱子/ barrels、打开菜单时光标上的物品,以及其他模组添加的容器。
- 限制仅匹配物品 ID。物品组件(自定义名称、附魔等)不予考虑,因此例如所有
minecraft:enchanted_book 物品都会合并计算。不支持物品标签(#minecraft:...)。
- 在游戏的背包顺序中,先减少散落物品,再减少容器内容,因此掉落的物品不一定是刚刚拾取的那个。但总数量始终正确。
- 掉落的物品可以在 5 秒后再次拾取,但如果玩家仍处于上限状态,数据包会再次将其掉落。
- 携带潜影盒或绑束的玩家会使检查成本略微增加。如果你不需要容器统计,请使用
/function item_limits:containers_off。
- 如果容器编辑因任何原因失败,则不会移除任何物品,也不会掉落任何物品;检查只会重试。
兼容性
- Minecraft Java Edition 26.3
- Vanilla, Fabric, Quilt, Paper, Purpur, Velocity-backed networks(数据包是单服务器级别的,需要在每个需要限制的后端服务器上安装它)
Item Limits
Configurable per-player item caps for Minecraft Java 26.3.
Limit how many of any item a player can carry, e.g. 1 Totem of Undying or 4 Enchanted Golden Apples. When a player is at the cap and picks up more, the extra items are dropped on the ground.
The pack ships empty: nothing is limited until you add limits yourself with simple /function commands. No config files, no restarts, no /reload needed.
Features
- Works on any item (vanilla item IDs)
- Add, change, remove and list limits in-game
- Excess items are dropped, never deleted (an item is only removed from the inventory after the drop was spawned successfully)
- Counts the whole player inventory: hotbar, main inventory, armor slots and offhand
- Also counts items inside shulker boxes and bundles (including bundles inside shulker boxes) that a player carries, so containers can't be used to get around a limit
- Optional chat message telling the player why an item was dropped
- Bypass tag for players who should be exempt (e.g. staff)
- Server-side only, no mods or resource pack needed
- Very lightweight: runs every 5 ticks and does nothing while no limits are configured
Installation
- Download
ItemLimits-1.1.0-mc26.3.zip.
- Put the zip in
world/datapacks/ of your server (or the world's datapacks folder in singleplayer).
- Run
/reload or restart the server.
Requires Minecraft Java Edition 26.3 (data pack format 121).
Commands
All commands need operator permissions (permission level 2, like any /function).
| Command |
What it does |
/function item_limits:add {item:"minecraft:totem_of_undying",max:1} |
Add a limit, or change it if one already exists for that item |
/function item_limits:remove {item:"minecraft:totem_of_undying"} |
Remove the limit for an item |
/function item_limits:list |
Show all configured limits |
/function item_limits:clear_all |
Remove every limit |
/function item_limits:messages_on |
Tell players when an extra item was dropped (default) |
/function item_limits:messages_off |
Do not send those messages |
/function item_limits:containers_on |
Count items inside shulker boxes and bundles (default) |
/function item_limits:containers_off |
Only count loose items (v1.0 behaviour) |
Examples
# Max 1 totem per player
/function item_limits:add {item:"minecraft:totem_of_undying",max:1}
# Max 4 enchanted golden apples per player
/function item_limits:add {item:"minecraft:enchanted_golden_apple",max:4}
# Change the totem limit to 2
/function item_limits:add {item:"minecraft:totem_of_undying",max:2}
# Remove the totem limit again
/function item_limits:remove {item:"minecraft:totem_of_undying"}
Tip: the item value is the normal item ID. Press F3 + H in game to see IDs in item tooltips. max:0 bans an item completely (everything gets dropped).
Exempt players
/tag <player> add item_limits.bypass
/tag <player> remove item_limits.bypass
How it works
Every 5 ticks, each player is checked against every configured limit. The total is the loose items plus everything inside shulker boxes and bundles the player carries. If a player carries more than allowed, the excess is dropped at their feet (with a 5 second pickup delay). Loose items are dropped first (normally the item that was just picked up). If the excess is inside a shulker box or bundle, it is taken out of that container, which stays in the same inventory slot, and dropped with its original components. If a player is far over a limit (for example because you just added a limit), up to 64 items are handled per check until they are within the limit.
Limits are stored in the item_limits:config command storage, so they are saved with the world and survive restarts and /reload.
Limitations
- Counted: the player's inventory, offhand and armor slots, plus the contents of shulker boxes and bundles in them (and bundles inside shulker boxes). Not counted: ender chests, chests/barrels in the world, items on the cursor while a menu is open, and containers added by other mods.
- Limits match on the item ID only. Item components (custom names, enchantments, ...) are not taken into account, so e.g. all
minecraft:enchanted_book items count together. Item tags (#minecraft:...) are not supported.
- Loose items are reduced before container contents, in the game's inventory order, so the dropped item is not necessarily the one that was just picked up. The total amount is always correct.
- A dropped item can be picked up again after 5 seconds, but the pack will simply drop it again if the player is still at the cap.
- Players carrying shulker boxes or bundles cost slightly more to check. Use
/function item_limits:containers_off if you do not need container counting.
- If a container edit fails for any reason, nothing is removed and nothing is dropped; the check simply tries again.
Compatibility
- Minecraft Java Edition 26.3
- Vanilla, Fabric, Quilt, Paper, Purpur, Velocity-backed networks (the pack is per-server, install it on each backend server that needs limits)
评论 0
登录后参与评分
还没有评论,来抢沙发吧