tModLoader Bags of Holding

Are you using the 0.9.2.1 tModLoader? This mod uses features that were implemented there. From what I could see from the error message, it seems to not be finding the ContainsKey method from TagIO, which was added in 0.9.2
Yeah playing on 0.9.2.1, guess ill hold off this mod til later when i update.
 
Ok, updated to tmod 0.10, and including a bunch of new features (aka, bags)

v1.1 Changelog:
- Updated for tmod v0.10 (Not fully re-tested, so things may have broken from before)
- Added Coin bag, that auto-picks-up coins and tries to save coins as a piggy bank would (max vaule coins).
- Added the Plant, Wood, Mushroom and Dye Material Bags, as well as their collective bag, the Nature Bag.
- Added the Fish, Bait and Crate Bags, as well as their collective bag, the Fishing Bag.
- Added the True Omni Bag, capable of storing anything that is stackable.

I'll update the main post later with the changes (and pretty pictures), for now, here's what's new (extracted from mod description):

- Wood Bag (woods and acorns), Plant Bag (alchemy plants and pumpkins and their seeds, and sunflowers), Mushroom Bag (Mushrooms and grass seeds), Dye Material Bag (for dye materials) and their collective bag, the Nature Bag.
- Fish Bag (fish and junk), Crate Bag (crates), Bait Bag (Bait, including truffle worm) and their collective bag, the Fishing Bag.
- Coin Bag, a special bag that collects the 4 normal coins and stacks them up into more valuable coins.
- The True Omni Bag, that collects everything that can be stacked (sorted by ItemID)

Also, "Deposit to Chest" functionality now works with piggy bank, defender's forge and safe, so you can easily drop your Coin Bag contents and use them in a shop.

EDIT: Version 1.2 for Tmod 0.10 released, here's what it adds.

v1.2 Changelog:
- Added compatibility with Magic Storage by Bluemagic. You can now use the bag on a Storage Heart, Crafting Access, Storage Access or Remote storage to automatically deposit all bag items inside (if they fit).
- Added Shift-click from inventory to add an item to the Bag from the inventory in the Bag UI.
- Fixed a bug with the True Omni Bag creation causing certain mod items not to be included in the permitted items.
 
Last edited:
Ok this is kind of awesome. I don't know of another mod on Terraria that is up to date that increases your inventory capacity. This, I have to try!
 
For some reason, even though my inventory is full, the gem bag won't pick up this emerald right next to me as seen here.
EJFBIfw.jpg
 
For some reason, even though my inventory is full, the gem bag won't pick up this emerald right next to me as seen here.

There was a bug where the bag would not pick up items that weren't already present in the bag if the inventory was full. Fixed in a new version, updated now to the mod browser.

v1.2.1 Changelog:
- Fixed a bug preventing bags from picking up items when the inventory was full and there was no item of that kind inside the bag.
 
For some reason I'm trying to deposit the items from my Omni Bag directly into the Magic Storage Access but it won't go in automatically.
etN4wOl.png
This is how i have the access set up, connected to a storage heart down at the bottom. I've had to manually dump the content into my inventory and put each thing into the storage rather than simply left clicking the bag over it.

Also, how come the gem bag won't take Amber?
 
Last edited:
Hey! I was wondering if I could use your mod with my own, as the mod i'm making is a magic backpack mod and i'm thinking of using the True Omni Bag with some of the Magic Storage components. Is this something you approve of? I don't want to be 'That' mod maker.
 
For some reason I'm trying to deposit the items from my Omni Bag directly into the Magic Storage Access but it won't go in automatically.
etN4wOl.png
This is how i have the access set up, connected to a storage heart down at the bottom. I've had to manually dump the content into my inventory and put each thing into the storage rather than simply left clicking the bag over it.
Also, how come the gem bag won't take Amber?
I re-tested the mod building a setup similar to yours and, for me, each of the bags (tested with true omnibag, omnibag, gem bag and coin bag) deposited all of their contents into the storage. It even worked with remote access, after linking it to the storage heart. I even tested the situation when you have limited storage space, and it correctly deposited only what the storage could handle. Do you have any more information to try and spot the bug?

Also, Amber thing was a leftover from when this was a Mining aid mod, Amber isn't minable. Should be fixed in next release.

Hey! I was wondering if I could use your mod with my own, as the mod i'm making is a magic backpack mod and i'm thinking of using the True Omni Bag with some of the Magic Storage components. Is this something you approve of? I don't want to be 'That' mod maker.

The code is available, so if you want to base your system out of mine, go right ahead. Just a few notes to simplify your life:
Most code for the bags is in GenericHoldingBag, including the deposit item in magic storage. Just be aware that I did not use weak references, just straight-up Reflection to load the code. Using weak references in your mod will simplify your life greatly. The functions for storing items in the chests, dropping on the floor and Magic storage storage are "emptyBagOnChest(Player p, int chest)" and "emptyBagOnBank(Player p, int chest)", "emptyBagOnFloor(Player p)" and "emptyBagOnMagicStorage(Player p)".
For the True Omni Bag, what it does is, after loading all mods, searches every item loaded for item.maxStack >1. This code is located at "BagPlayer.cs".

For getting to the code, simply use tModReader.
 
I know this may have been asked before, but is it possible to make the bags work from your inventory rather than from an accessory slot? If it is but isn't implemented for balancing reasons, could you at least make it a config option? or maybe make an special slot you put your bag in, like the grappling hook or mount slots. That's the only gripe i have with this mod, having to give up an accessory slot and having to remember to unequip/reequip your bag/accesories. Even if you don't change it, this is still one of the best QoL mods out there imo, just like your other mods.
 
havent changed any code but this happened
The process cannot access the file 'C:\Users\alexi\OneDrive\Documents\My Games\Terraria\ModLoader\Logs\Logs.txt' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
at System.IO.StreamWriter.CreateFile(String path, Boolean append, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append, Encoding encoding, Int32 bufferSize, Boolean checkHost)
at System.IO.StreamWriter..ctor(String path, Boolean append)
at System.IO.File.AppendText(String path)
at Terraria.ModLoader.ErrorLogger.Log(String message)
at JPANsBagsOfHoldingMod.BagPlayer.PreUpdate() in d:\Users\JPAN\Documents\My Games\Terraria\ModLoader\Mod Sources\JPANsBagsOfHoldingMod\BagPlayer.cs:line 47
at Terraria.ModLoader.PlayerHooks.PreUpdate(Player player)
at Terraria.Player.Update(Int32 i)
at Terraria.WorldGen.do_playWorldCallBack(Object threadContext)
at Terraria.WorldGen.playWorldCallBack(Object threadContext)
 
The bag GUIs are rather laggy for me, when they are open (note FPS in video). Seems to be the case even when the bag is empty. But it only seems to be really laggy when there are a lot of modded items registered (e.g. from having many mods enabled).

  • tModLoader version: 0.10.0.2 (but also reproducible on 0.10.0.1)
  • Bags of Holding version: 1.2.1
  • Bags tested: Coin, bait, fishing
  • Mods enabled: AlchemistNPC, HEROsMod, JPANsBagsOfHoldingMod, Antisocial, AutoTrash, BossChecklist, BossLootPlus, CalamityMod, chadsfurni, CosmeticVariety, CrystiliumMod, EnemyModifiers, FKBossHealthBar, HelpfulHotkeys, imkSushisMod, Infinity, ItemChecklist, LootBags, MagicStorage, MoreAccessories, MoreChestLoot, OmniSwingX, PillarItemsPlus, PlayerHealthManaBar, RecipeBrowser, ReducedGrinding, ShorterRespawn, SpiritMod, SummonersAssociation, TheDeconstructor, Tremor, VanillaTweaks, VariablePotionSickness, WorldGenPreviewer, Fargowiltas
I tried to figure this out by profiling Terraria in Visual Studio. What I found was that Terraria's checkMat() method was taking up the most CPU time, but this is being called for each slot by GenericHoldingBag.cs. I believe checkMat() is iterating through every single registered modded item (of which, there are thousands in my setup).

Is it possible for the UI code to not use SetDefaults() or otherwise optimize the UI drawing code for many registered items? I'm unfamiliar with Terraria or tModLoader so I can't really help further. I should note that vanilla inventories (e.g. chests) and inventories from other mods don't appear to have this issue.

Thanks for this mod; the coin bag has been very helpful!
 
The bag GUIs are rather laggy for me, when they are open (note FPS in video). Seems to be the case even when the bag is empty. But it only seems to be really laggy when there are a lot of modded items registered (e.g. from having many mods enabled).

I tried to figure this out by profiling Terraria in Visual Studio. What I found was that Terraria's checkMat() method was taking up the most CPU time, but this is being called for each slot by GenericHoldingBag.cs. I believe checkMat() is iterating through every single registered modded item (of which, there are thousands in my setup).
CheckMat calls for every Recipe/RecipeGroup each time an item is instantiated. BagUI Called setDefaults with material check for every item in display every tick. Very inefficient, but it was my first UI and I didn't really think of it much. But really, things can be much more efficient. To try and fix this problem, I made the following changes:
- getItemFromTag now checks if an item is type == 0 (empty item) before calling the setDefaults.
- BagUI now keeps a List of token Items for every Item inside a bag. While this will be slow in the cases where there are lots of different items (like an almost filled True Omni Bag), It is so unlikely this will happen that it's still an upgrade from generating a new item each time a slot gets displayed.
- Functions where the items are moved from place to place now Clone each other instead of creating new instances from SetDefaults, reducing calls to checkMat.

I uploaded a new version to ModBrowser with these changes. I tested it a bit and it seems to work as expected, but I'm not very sensible to FPS changes, so check it out and report back if it still isn't fixed for you.
 
...I uploaded a new version to ModBrowser with these changes. I tested it a bit and it seems to work as expected, but I'm not very sensible to FPS changes, so check it out and report back if it still isn't fixed for you.

Yep! Updated and with both bags open, I get a smooth 60FPS again. Thank you very much for the quick fix!
 
Im also having a problem similar to what channy5 is having. However i am running a pretty big mod list, but im pretty sure i know the culprit, the omniswingx mod (makes every item in the game and probably mods auto swingable.). I am also unable to deposit to chest it's on a multiplayer server as well if that makes any difference.

Anyways great mod and keep up the good work! <3 <3
 
Hey, was wondering if you could remove coins from the true omni bag. I am running magic storage with your mod and several times my storage system has become overloaded with thousands of stacks of copper coins
 
Back
Top Bottom