Skip to content

1.21.1 containers

github-actions[bot] edited this page Dec 3, 2026 · 9 revisions

Containers

A container is storage: barrels, chests, shulkers and backpacks. They share an inventory, a search field and a sort button, and differ in shape, in how they are placed, and in what happens when you break one.

{
  "id": "ruby_barrel",
  "type": "container",
  "names": { "en_us": "Ruby Barrel", "es_mx": "Barril de Rubí" },
  "container": {
    "type": "barrel",
    "slots": 45
  }
}

The four types

container.type is required. The four differ in whether breaking one keeps its contents, and a silent default would decide that behind your back.

Type Shape Placed Keeps contents
barrel A full cube, with a real open state Facing any of six directions No
chest The vanilla chest, with an animated lid Horizontally; joins in a pair No
shulker Attaches to a surface, lid slides out On the face you click Yes
backpack Not a block — an item you carry — Yes

A barrel costs nothing to draw: its whole appearance is generated JSON. A chest and a shulker need a renderer, which is what buys them their animation.

Fields

Field Type Default Description
container.type String required barrel, chest, shulker or backpack
container.slots Number required Total slots, at least 1. Not rows × columns — the last row may be partial
container.columns Number automatic Slots per row. Presentation only
container.max_columns Number 12 Ceiling for the automatic width. Ignored when columns is declared
container.keeps_contents Boolean by type Whether breaking it stores the contents in the dropped item
container.openable_when_obstructed Boolean by type Whether it opens with a solid block in the way
container.accessory_slots List empty (Backpacks only) Accessory slots it can be worn in (Curios or Trinkets)
required_tool String by type Tool that breaks it faster, as on a block: axe for barrels and chests, pickaxe for shulkers, like vanilla. none for no tool. Without a harvest_level it still drops by hand

Block fields

A barrel, chest or shulker is also a block, so it takes the block fields that shape how it breaks and looks in the world: destroy_time, explosion_resistance, sound, map_color, light_level, harvest_level and required_tool. directional and gravity do not apply: each type already decides how it is placed. Left out, destroy_time and explosion_resistance take vanilla's values, so it breaks like its vanilla counterpart: 2.5 for barrels and chests, 2.0 for shulkers. A backpack is an item and takes none of them.

Slot count

There is no hard ceiling, but past 128 the parser warns you. That is where vanilla's click packet gives up: a single action changing more slots than that at once — a long drag, a mass shift-click — disconnects the player with an encoder error. Hard to reach in survival, trivial in creative.

slots is baked when the container is registered, so changing it needs a restart, not /customgear reload. Shrinking a container that already holds more than fits drops the excess on the ground; growing one simply adds empty slots at the end.

Column count

Omit columns and the width is worked out so the contents fit in nine rows, capped by max_columns:

Slots Columns Rows
45 9 5
81 9 9
108 12 9
200 12 scrolls

Declare columns and that exact width is used, however tall the result gets.

There is no horizontal scrolling, so a width too large for the player's window cannot simply be drawn — the screen re-flows the same slots into fewer columns instead. No slot is ever unreachable, but a very wide container looks different on a small window than you designed it.

Keeping contents

keeps_contents decides what breaking one does. Defaults to true for shulkers and backpacks, false for barrels and chests — but it is yours to set, and a barrel that keeps its contents is perfectly legal.

A backpack cannot turn it off: it has no block to store an inventory in, so the contents live in the item or nowhere.

A container that keeps its contents does not stack, for the same reason vanilla's shulker box does not: stacking two would merge them into one inventory.

Chests

Two chests placed side by side, facing the same way, join into a double with twice the slots. Crouch while placing to keep them separate.

The pair holds one inventory rather than two. That is invisible in play — breaking either half hands back that half's contents exactly as vanilla does, and Ctrl+picking one in creative copies only it's half — but it is why hoppers, comparators and mod overlays read the same thing from either side.

A chest that keeps its contents cannot join into a double: there would be no answer to which half the dropped item carries. Set keeps_contents on a chest and it stays single.

Joining or splitting a pair changes the inventory's size, so anyone with the screen open is kicked out of it. Reopening takes a click; a window whose slots no longer line up would be a bug report.

Shulkers

A shulker attaches to whatever surface you place it against and its lid slides out of that face. Put one on the floor, and it opens upward; stick it to a wall, and it opens toward you.

Its collision box grows while the lid rises, so it pushes entities out of the way and refuses to open when there is no room. That is not just fidelity: against a solid block there would be nowhere to push them to.

Backpacks

A backpack is carried rather than placed. Open it with right click, or with the Open backpack keybind (B by default) from anywhere in your inventory.

The keybind looks in this order:

  1. The selected hotbar slot
  2. The offhand
  3. Equipped accessory slots (Curios or Trinkets)
  4. The rest of the inventory, hotbar first

Equipped beats loose on purpose — someone wearing a storage ring is wearing it to have it at hand.

While its screen is open the slot holding it is frozen, so it cannot be dragged out or dropped from inside its own inventory. If it leaves anyway — taken by another player, pulled by a hopper, lost on death — the screen closes by itself.

Accessory slots

accessory_slots lists the accessory slots this backpack can be worn in: Curios on NeoForge, Trinkets on Fabric.

{
  "container": {
    "type": "backpack",
    "slots": 27,
    "accessory_slots": ["back", "charm"]
  }
}

Write a slot the Curios way, one word (back), or the Trinkets way, group and slot (chest/back). Where the other mod has a slot that means the same, the name is translated for it, so the same file works on both loaders. Where it has none, the slot only exists with the mod that ships it: on the other loader that entry does nothing, and the log says so when the pack loads. A backpack that lists one slot of each kind, such as ["head/face", "bracelet"], is worn on the face on Fabric and on the bracelet on NeoForge.

These are all the slots Curios ships (NeoForge):

Curios Meant for On Trinkets (Fabric)
back backpacks, wings chest/back
belt belts legs/belt
body capes, cloaks chest/cape
bracelet bracelets none
charm charms, trinkets none
curio anything, a generic slot none
hands gloves hand/glove and offhand/glove
head hats, crowns head/hat
necklace necklaces, amulets chest/necklace
ring rings hand/ring and offhand/ring

These are all the slots Trinkets ships (Fabric), as group/slot:

Trinkets Meant for On Curios (NeoForge)
head/hat hats, crowns head
head/face masks, glasses none
chest/back backpacks, wings back
chest/cape capes, cloaks body
chest/necklace necklaces, amulets necklace
legs/belt belts belt
feet/shoes shoes none
feet/aglet shoe accessories none
hand/glove gloves, main hand hands
hand/ring rings, main hand ring
offhand/glove gloves, off hand hands
offhand/ring rings, off hand ring

Curios' hands and ring belong to neither hand, while Trinkets has a glove and a ring slot on each. So hands fits both glove slots on Fabric, and either glove slot fits hands on NeoForge; the same goes for ring.

Other mods can add more slots to either one. A name that is in neither table is used as written for the mod whose form it is in, and the log warns about it rather than rejecting it, in case it is a misspelling.

The slots you declare are also assigned to the player, so they exist without needing another mod to provide them. Only the declared ones — installing this mod to make a sword does not fill your accessory inventory with empty slots.

Changing accessory_slots needs /reload as well as /customgear reload. Curios and Trinkets read their slot assignment outside the reload this mod triggers. The log warns you when the set changes.

Both mods are optional: without them accessory_slots simply does nothing.

Nesting

Containers that carry their contents in the item refuse to hold another one, and refuse to go inside one. That includes vanilla's shulker boxes, in both directions.

The reason is not tidiness. Contents live in the item's components, so a container inside a container nests NBT, and each level multiplies the size of the outer stack — which travels the network every time it moves in an inventory. At a few hundred slots that reaches the packet limit and disconnects the player.

A container that spills when broken carries no NBT, so it nests freely: a plain barrel goes inside a shulker without trouble, and shulkers go inside chests as they always have.

Textures

Each type takes different keys, and giving one the wrong keys is an error rather than a silent fallback:

Type Keys What each is
barrel top, bottom, side, top_open, particle Block faces, like any block. top_open is the lid while open
chest single, left, right, particle 64×64 unwraps, one per half
shulker single, particle A 64×64 unwrap
backpack item, item_open 16×16 item textures. item_open replaces item while the backpack is open

particle is the texture the container breaks into, as on any block. Without it a barrel uses its side, and a chest or shulker a 16×16 piece of the lid cut from its own single texture, or vanilla's oak planks or shulker box when it declares none.

A chest's halves are not the single texture cropped: they are 15 pixels wide instead of 14 and laid out differently. A chest that can join into a double and declares only single will show vanilla's halves when paired, and the parser warns about it.

The easiest way to make one is to extract vanilla's and paint over it. They live in the version jar under assets/minecraft/textures/entity/: chest/normal.png, chest/normal_left.png, chest/normal_right.png and shulker/shulker.png.

A backpack that declares neither texture uses vanilla's bundle, tied shut and open: minecraft:item/bundle_filled and minecraft:item/bundle (in 1.21.1 the names are the wrong way round). With only item, it looks the same open or closed. Only you see your own backpack open.

See Textures & Models for how a value is read.

The screen

Every container opens the same screen, with these on its title bar:

  • Search. Click the field and type; right-click it to clear. Only the matching items stay in view. A plain word matches the item's name, and a prefix changes what it matches: @ the mod, # a tag, $ the tooltip, * the item id. Spaces mean all the terms must match, and | separates alternatives: @minecraft #ingots | diamond. The phrase stays when you close the container and is shared by all of them, so a search typed in one chest still filters the next one. To open each container unfiltered, set keep_search_phrase = false under [containers] in config/customgear-client.toml, or turn off "Keep Search" in the mod's config screen.
  • Sort. The criterion button cycles through name, mod, count and tag. Left-click the sort button to sort; right-click it to flip the order. The middle mouse button sorts too, anywhere outside your own inventory.
  • Transfer. The two arrow buttons move items into the container or out of it. On their own they only move item types the other side already holds, which tops up a chest without dumping everything into it. Hold Shift to move everything that fits. The hotbar is never touched.

The sort and transfer actions also have keys (Sort container, Transfer to container, Transfer to inventory) under Custom Gear in the controls' menu. The transfers start unbound.

Tooltips

Hold Shift over a container that holds something and its contents show as a grid of items, most numerous first, with "…and N more types" when there are too many to fit.

A container that can hold contents says so even when empty, so the key is discoverable rather than something you find by accident.

Limitations

  • Past 128 slots a single action can disconnect the player. See above
  • A backpack's contents travel inside its ItemStack, re-sent every time anything moves in the player's inventory. A large backpack full of items with heavy NBT is where slot count costs the most
  • Trying to nest a container flickers for a frame before the server refuses it: the client's stand-in inventory knows the rule, but the prediction runs first
  • slots needs a restart; everything else about a container is hot-reloadable

Clone this wiki locally