Bag mode
Letting a builder wand pull its blocks out of an InfiniteBags bag, and how the switch is remembered.
With InfiniteBags installed, a builder wand can take the blocks it places straight out of the player's bag instead of their inventory. Players switch it on and off themselves, on the wand, and the choice sticks.
Bag mode needs InfiniteBags 1.3.0 or newer. The two methods it relies on, counting a bag and taking items back out of one, arrived in that release. On 1.2.3 and older the hook says so once in the console, bag use stays off, and the wand quietly falls back to the inventory or to buying.
Switching it on
The player holds the builder wand and does the configured action at the air, not at a block. The default is sneak and right-click:
bag-toggle:
# sneak-right-click-air, right-click-air, sneak-left-click-air or left-click-air
action: sneak-right-click-airThey get a short message either way, and the wand's lore updates on the spot.
Only builder wands respond to this. A sell wand ignores the toggle entirely, because a sell wand never touches a bag.
Where the blocks come from with it on
| Mode | Order |
|---|---|
build-inventory, source-order: inventory | Inventory, then the bag |
build-inventory, source-order: bag | The bag, then the inventory |
build-shop | The bag, then buy the rest |
Shop mode always empties the bag before it charges anyone, whatever building.source-order says. Taking free blocks first is always the better deal for the player.
What counts as a match
The bag is asked about the plain block, and InfiniteBags groups items on material plus their full item data, exactly the way its own contains check does. A renamed or enchanted block sitting in the bag is never consumed to place a plain one.
Taking from the bag is partial by design. Ask for five when the bag holds three and it hands over three, and the wand carries on to its next source for the other two.
The player's own bag switch
InfiniteBags has its own per player switch, and a wand honours it. If a player has turned their bag off there, the wand does not draw from it even with bag use on. Nothing breaks and nothing is said: the wand falls back to the inventory, or to buying in shop mode.
Bag use on the wand and the player's bag being on in InfiniteBags are two separate switches. Both have to be on for a wand to reach the bag. If a player says bag mode is doing nothing, check the second one.
How the choice is remembered
Two things store it, and they answer different questions.
The switch is written into the wand item itself. Two wands of the same id in the same inventory can be on different settings, and handing a wand to someone else hands over its current state with it.
The last choice a player made is also saved against their name in the database. When they are given a fresh wand it starts on that, rather than always starting off.
A player who has never touched the toggle has nothing saved, so their first wand falls back to bag-default on the wand in wands.yml. That is what bag-default is for.
Showing it in the lore
Put {bag} in a lore line and it prints the current state:
lore:
- "&fBag use: &b{bag}"The words themselves come from your language file, so they translate:
placeholders:
bag-on: "on"
bag-off: "off"On a server with no InfiniteBags, every lore line containing {bag} is dropped from the item rather than printed as "off". A row that can never say anything useful is worse than no row.
Turning the hook off
hooks:
infinitebags:
enabled: trueSet it to false and WandWorks never looks for InfiniteBags, even when it is installed. Bag mode then behaves exactly as it does on a server without the plugin.
When it will not switch on
| What the player sees | Why |
|---|---|
| Bag use needs InfiniteBags, which is not installed | The plugin is missing, or hooks.infinitebags.enabled is false |
| Bag use needs InfiniteBags 1.3.0 or newer | InfiniteBags is running but is too old to take items out of a bag |
Both messages are yours to edit, under build.bag-unavailable and build.bag-outdated. See Messages and language.
Console lines worth knowing
If bag mode is not doing anything, the console will have said why at startup.
| Line | What it means |
|---|---|
| InfiniteBags is installed but its API is not ready | InfiniteBags loaded but had not finished starting |
| InfiniteBags is installed but its API could not be read | The API could not be reached at all. Usually a shaded or relocated copy |
| InfiniteBags is installed but its API cannot take items out of a bag | InfiniteBags is older than 1.3.0 |
| A call into InfiniteBags failed, bag use will act as an empty bag | A call threw. Printed once, then the wand treats the bag as empty |