CC: Bundles

Quick rating

Community listing page, reviews may not be monitored by the author.

CC: Bundles

By OdiumTruesOwner

No reviews yet

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

Mod Loaders
Minecraft
26.2

About

Description

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