跳到正文

CC: Bundles

作者:OdiumTrues

Allows CC: Tweaked turtles to equip and use vanilla Minecraft bundles.

收藏

截图

介绍

中文介绍正在准备中,下面暂时显示原文。

CC:Bundles

CC:Bundles allows CC:Tweaked turtles to equip and use vanilla Minecraft bundles as inventory peripherals.

  • Regular bundles + all 16 dyed variants
  • Preserves bundle color and contents when equipped/unequipped
  • CC:Tweaked-style inventory API
  • Bundle capacity utilities
  • bundleCost item information
  • Direct access to the turtle’s inventory
  • Dump bundle contents into the world

API

| Method | Description |
| — | — |
| size() | Number of unique item variants |
| list() | List bundle contents |
| getItemDetail(slot) | Detailed item info, including bundleCost |
| getItemLimit(slot) | Item limit for a virtual slot |
| pushItems(toName, fromSlot [, limit [, toSlot]]) | Move items out of the bundle |
| pullItems(fromName, fromSlot [, limit [, toSlot]]) | Move items into the bundle |
| slotsFull() | Used capacity out of 64 |
| slotsFree() | Remaining capacity out of 64 |
| dump() | Dump all contents in front of the turtle |

Inventory methods follow the conventions of CC:Tweaked’s generic inventory peripheral.

Using a Bundle

Once equipped, wrap the bundle as a peripheral:

local bundle = peripheral.wrap("left")

or:

local bundle = peripheral.wrap("right")

Virtual Slots

Bundles do not have fixed inventory slots.

Each unique stored item variant is exposed as a virtual slot:

{
    [1] = {
        name = "minecraft:oak_planks",
        count = 12
    },

    [2] = {
        name = "minecraft:diamond",
        count = 3
    }
}

Items with different components or stored data are separate variants.

Virtual slot numbers may change when contents change.

size() returns the number of current virtual slots, not a fixed inventory size.

bundleCost

getItemDetail(slot) includes:

bundleCost

Capacity used by one item:

64-stackable item  = 1
16-stackable item  = 4
non-stackable item = 64

Example:

local item = bundle.getItemDetail(1)

print(item.name)
print(item.count)
print(item.bundleCost)

CC:Bundles also adds bundleCost to:

turtle.getItemDetail(slot, true)

The second argument must be true.

local item = turtle.getItemDetail(4, true)

if item then
    print(item.bundleCost)
end

This can be used with slotsFree() to determine how many items will fit:

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

Moving Items

pullItems() moves items into the bundle:

bundle.pullItems(fromName, fromSlot [, limit [, toSlot]])

pushItems() moves items out of the bundle:

bundle.pushItems(toName, fromSlot [, limit [, toSlot]])

Both return the number of items moved.

Turtle Inventory

Turtle slot 4 → bundle:

bundle.pullItems("turtle", 4)

At most 8 items:

bundle.pullItems("turtle", 4, 8)

Bundle slot 1 → turtle:

bundle.pushItems("turtle", 1)

Into turtle slot 6:

bundle.pushItems("turtle", 1, 8, 6)

Other inventories use their normal peripheral names.

Bundle Capacity

bundle.slotsFull()
bundle.slotsFree()

Both use Minecraft’s actual bundle capacity rules.

bundle.slotsFull() + bundle.slotsFree()

always equals:

64

Dumping Contents

local count = bundle.dump()

dump():

  • Dumps the entire bundle in front of the turtle

Example: Find an Item

for slot, item in pairs(bundle.list()) do
    if item.name == "minecraft:diamond" then
        print(slot, item.count)
    end
end

Documentation

常见问题

CC: Bundles 支持哪些 Minecraft 版本?

CC: Bundles 支持 Minecraft Java 版 26.2,可用的加载器:Fabric。下载时注意选择和你游戏版本一致的文件。

CC: Bundles 怎么安装?

先用 PCL2 或 HMCL 启动器安装对应版本的 Fabric,再把下载的 .jar 文件放进游戏目录的 mods 文件夹,重新启动游戏即可。开启了版本隔离的,mods 文件夹在 versions/版本名 下面。运行环境:客户端和服务端都要装。

评论

登录后评论和评分