CC:Bundles
CC:Bundles 允许 CC:Tweaked 的挖掘者装备并使用原版 Minecraft 的 Bundle(收纳袋)作为库存外围设备。
- 普通收纳袋 + 全部 16 种染色变体
- 装备/卸下时保留收纳袋的颜色和内容物
- 采用 CC:Tweaked 风格的库存 API
- 收纳袋容量工具函数
bundleCost物品信息- 直接访问挖掘者的库存
- 将收纳袋内容物倾倒到世界中
API
| 方法 | 描述 |
|---|---|
size() |
唯一物品变体的数量 |
list() |
列出收纳袋内容物 |
getItemDetail(slot) |
详细的物品信息,包括 bundleCost |
getItemLimit(slot) |
虚拟槽位的物品上限 |
pushItems(toName, fromSlot [, limit [, toSlot]]) |
将物品移出收纳袋 |
pullItems(fromName, fromSlot [, limit [, toSlot]]) |
将物品移入收纳袋 |
slotsFull() |
已使用的容量(总共 64) |
slotsFree() |
剩余容量(总共 64) |
dump() |
将全部内容物倾倒出来 |
库存方法遵循 CC:Tweaked 的通用库存外围设备的约定。
使用收纳袋
装备后,将收纳袋包装为外围设备:
local bundle = peripheral.wrap("left")
或:
local bundle = peripheral.wrap("right")
虚拟槽位
收纳袋没有固定的库存槽位。
每个存储的唯一物品变体都作为一个虚拟槽位暴露:
{
[1] = {
name = "minecraft:oak_planks",
count = 12
},
[2] = {
name = "minecraft:diamond",
count = 3
}
}
具有不同组件或存储数据的物品是独立的变体。
当内容物改变时,虚拟槽位编号可能会发生变化。
size() 返回当前虚拟槽位的数量,而不是固定的库存大小。
bundleCost
getItemDetail(slot) 包含:
bundleCost
单个物品占用的容量:
64堆叠物品 = 1
16堆叠物品 = 4
不可堆叠物品 = 64
示例:
local item = bundle.getItemDetail(1)
print(item.name)
print(item.count)
print(item.bundleCost)
CC:Bundles 还将 bundleCost 添加到:
turtle.getItemDetail(slot, true)
第二个参数必须为 true。
local item = turtle.getItemDetail(4, true)
if item then
print(item.bundleCost)
end
这可以与 slotsFree() 配合使用,以确定能容纳多少物品:
local item = turtle.getItemDetail(4, true)
if item then
local maxFit = math.floor(bundle.slotsFree() / item.bundleCost)
bundle.pullItems(
"turtle",
4,
math.min(item.count, maxFit)
)
end
移动物品
pullItems() 将物品移入收纳袋:
bundle.pullItems(fromName, fromSlot [, limit [, toSlot]])
pushItems() 将物品移出收纳袋:
bundle.pushItems(toName, fromSlot [, limit [, toSlot]])
两者均返回移动的物品的数量。
挖掘者库存
挖掘者槽位 4 → 收纳袋:
bundle.pullItems("turtle", 4)
最多 8 个物品:
bundle.pullItems("turtle", 4, 8)
收纳袋槽位 1 → 挖掘者:
bundle.pushItems("turtle", 1)
进入挖掘者槽位 6:
bundle.pushItems("turtle", 1, 8, 6)
其他库存使用其正常的外围设备名称。
收纳袋容量
bundle.slotsFull()
bundle.slotsFree()
两者均使用 Minecraft 的实际收纳袋容量规则。
bundle.slotsFull() + bundle.slotsFree()
始终等于:
64
倾倒内容物
local count = bundle.dump()
dump():
- 将收纳袋的全部内容物倾倒到挖掘者前方
示例:查找物品
for slot, item in pairs(bundle.list()) do
if item.name == "minecraft:diamond" then
print(slot, item.count)
end
end
文档
你是这个资源的作者?登录后可认领此资源。
相似资源
可定制的鞘翅模组,支持装饰纹饰、旗帜图案等更多功能!
一个用于收集生物掉落物的多区块模组。
显示你正在注视的方块的信息。(适用于 Minecraft 1.16+ 的 Hwyla/Waila 分支)
使用 JavaScript 编辑配方、添加自定义物品、编写世界事件!
查看物品与配方
在游戏画面角落显示附近世界地形、玩家、生物和实体的地图。可创建路径点,帮助你找到标记过的位置。
评论 0
登录后参与评分
还没有评论,来抢沙发吧