public override bool ShiftClickSlot(Item[] inventory, int context, int slot) { if ((context != ItemSlot.Context.InventoryItem && context != ItemSlot.Context.InventoryCoin && context != ItemSlot.Context.InventoryAmmo) || slot == 58) { return(false); } if (GenericBagUI.visible) { GenericHoldingBag bag = GenericBagUI.openBag; if (bag != null) { Item selected = inventory[slot]; int oldStack = selected.stack; bag.addItem(selected); if (selected.stack <= 0) { inventory[slot] = new Item(); } if (oldStack != selected.stack) { GenericBagUI.buildItem(); } return(true); } } return(base.ShiftClickSlot(inventory, context, slot)); }
public override bool UseItem(Player p) { //if(p.selectedItem == 58) //return false; //Player owner = Main.player[item.owner]; if (Main.netMode == NetmodeID.Server || p.whoAmI != Main.myPlayer) { return(true); } if (order == null) { setupItemList(); } if (p.altFunctionUse == 2) { if (GenericBagUI.visible) { BagsOfHoldingMod.bagUIState.close(false); } else { BagsOfHoldingMod.bagUIState.open(p, this, false); } } else if ((leftClickOnPiggyBank || leftClickOnChest || leftClickOnFloor) && HasContent()) { if (leftClickOnPiggyBank || leftClickOnChest) { int chest = getChestAtTarget(p); if (chest >= 0) { ErrorLogger.Log("Chest is no. " + chest); if (Main.netMode == NetmodeID.MultiplayerClient) { ModPacket pack = mod.GetPacket(); pack.Write((byte)1); pack.Write((byte)p.whoAmI); pack.Write((byte)p.selectedItem); pack.Write((int)chest); pack.Write((int)Player.tileTargetX); pack.Write((int)Player.tileTargetY); TagIO.Write(items, pack); pack.Send(); } else if (Main.netMode == NetmodeID.SinglePlayer) { if (Main.chest[chest] != null && !IsPlayerInChest(chest) && !Chest.isLocked(Main.chest[chest].x, Main.chest[chest].y)) { emptyBagOnChest(p, chest); } } return(true); } else if (chest < -1 && chest > -5) { if (p.chest != chest) { if (Main.netMode != NetmodeID.Server) { emptyBagOnBank(p, chest); } return(true); } } else if (chest == Int32.MinValue) { if (Main.netMode == NetmodeID.MultiplayerClient) { ModPacket pack = mod.GetPacket(); pack.Write((byte)1); pack.Write((byte)p.whoAmI); pack.Write((byte)p.selectedItem); pack.Write((int)chest); pack.Write((int)Player.tileTargetX); pack.Write((int)Player.tileTargetY); TagIO.Write(items, pack); pack.Send(); } if (Main.netMode == NetmodeID.SinglePlayer) { emptyBagOnMagicStorage(p, Player.tileTargetX, Player.tileTargetY); } } else { if (leftClickOnFloor) { emptyBagOnFloor(p); } } } else { if (leftClickOnFloor) { emptyBagOnFloor(p); } } if (GenericBagUI.visible && GenericBagUI.openBag == this) { GenericBagUI.buildItem(); } } return(true); }