public override void Action(CommandCaller caller, string input, string[] args) { if (args.Length != 1) { BagsOfHoldingMod.sendChat("Use with \"reloadOrder\" with a held bag to reload its order, \"reloadOmnibag\" to reload omnibag's content list and \"remakeBags\" to remake all bag orders into the configs."); return; } if ((args[0].Equals("reloadOrder") || args[0].Equals("\"reloadOrder\"")) && caller.Player.HeldItem.modItem != null && caller.Player.HeldItem.modItem is GenericHoldingBag) { GenericHoldingBag bag = caller.Player.HeldItem.modItem as GenericHoldingBag; bag.setupItemList(); BagsOfHoldingMod.sendChat("Reloaded bag order"); return; } if (args[0].Equals("reloadOmnibag") || args[0].Equals("\"reloadOmnibag\"")) { TrueOmniBag.contents2 = null; BagPlayer.reloadOmnibag(); BagsOfHoldingMod.sendChat("Recreated Omnibag order."); return; } if (args[0].Equals("remakeBags") || args[0].Equals("\"remakeBags\"")) { GenericHoldingBag bg = new BaitBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new ChunkBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new CoinBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new CrateBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new DirtBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new DyeMaterialBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new FishBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new GemBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new MushroomBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new OreBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new PlantBag(); resetBagConfig(bg); bg.remakeFromConfig(); bg = new WoodBag(); resetBagConfig(bg); bg.remakeFromConfig(); FishingBag.resetContents(); NatureBag.resetContents(); OmniBag.resetContents(); BagsOfHoldingMod.sendChat("Reset all bag orders to the original order list."); } }
public virtual void emptyBagOnMagicStorage(Player p, int x, int y) { Mod magicStorage = ModLoader.GetMod("MagicStorage"); if (magicStorage != null) { try { if (Main.tile[x, y].frameX % 36 == 18) { x--; } if (Main.tile[x, y].frameY % 36 == 18) { y--; } ModTile t = TileLoader.GetTile(Main.tile[x, y].type); MethodInfo getHeart = (t.GetType()).GetMethod("GetHeart", BindingFlags.Public | BindingFlags.Instance, null, new Type[] { typeof(int), typeof(int) }, null); if (getHeart == null) { BagsOfHoldingMod.debugChat("GetHeart() is null. Report to author."); ErrorLogger.Log("GetHeart() is null on " + (Main.netMode == NetmodeID.MultiplayerClient ? "client" : "server")); return; } object[] param = new object[2]; param[0] = x; param[1] = y; TileEntity heart = (TileEntity)getHeart.Invoke(t, param); if (heart == null) { BagsOfHoldingMod.sendChat("This Access does not have an associated Storage Heart."); return; } Type[] depCal = new Type[1]; depCal[0] = typeof(Item); MethodInfo deposit = heart.GetType().GetMethod("DepositItem", BindingFlags.Public | BindingFlags.Instance, null, depCal, null); if (deposit == null) { BagsOfHoldingMod.debugChat("DepositItem(Item) is null. Report to author."); ErrorLogger.Log("DepositItem(Item) is null on " + (Main.netMode == NetmodeID.MultiplayerClient ? "client" : "server")); return; } for (int i = 0; i < order.Count; i++) { if (items.ContainsKey(order[i])) { long remain = items.GetAsLong(order[i]); bool prematureBreak = false; while (remain > 0 && !prematureBreak) { Item itm = getItemFromTag(order[i]); int stackSize = (int)Math.Min(remain, itm.maxStack); itm.stack = stackSize; deposit.Invoke(heart, new object[] { itm }); if (itm.IsAir) { remain -= stackSize; } else { remain -= (stackSize - itm.stack); prematureBreak = true; } } items.Remove(order[i]); if (remain > 0) { items[order[i]] = remain; } } } }catch (Exception e) { BagsOfHoldingMod.debugChat(e.ToString()); } if (Main.netMode == NetmodeID.MultiplayerClient) { ModPacket pack = mod.GetPacket(); pack.Write((byte)2); pack.Write((byte)p.whoAmI); pack.Write((byte)p.selectedItem); TagIO.Write(items, pack); pack.Send(); } } }