638 {
639 Player player = Main.player[Main.myPlayer];
640 bool flag = Main.mouseLeftRelease && Main.mouseLeft;
641 if (flag)
642 {
644 {
645 return;
646 }
647 inv[slot].newAndShiny = false;
649 {
650 return;
651 }
652 }
654 if (num != 3 && !flag)
655 {
656 return;
657 }
658 switch (num)
659 {
660 case 0:
661 if (context == 6 && Main.mouseItem.type != 0)
662 {
663 inv[slot].SetDefaults();
664 }
665 if (context == 11 && !inv[slot].FitsAccessoryVanitySlot)
666 {
667 break;
668 }
669 Utils.Swap(ref inv[slot], ref Main.mouseItem);
670 if (inv[slot].stack > 0)
671 {
672 AnnounceTransfer(
new ItemTransferInfo(inv[slot], 21, context, inv[slot].stack));
673 }
674 else
675 {
676 AnnounceTransfer(
new ItemTransferInfo(Main.mouseItem, context, 21, Main.mouseItem.stack));
677 }
678 if (inv[slot].stack > 0)
679 {
680 switch (context)
681 {
682 case 0:
684 break;
685 case 8:
686 case 9:
687 case 10:
688 case 11:
689 case 12:
690 case 16:
691 case 17:
692 case 25:
693 case 27:
694 case 33:
696 break;
697 }
698 }
699 if (inv[slot].
type == 0 || inv[slot].stack < 1)
700 {
701 inv[slot] =
new Item();
702 }
703 if (Main.mouseItem.IsTheSameAs(inv[slot]))
704 {
705 Utils.Swap(ref inv[slot].favorited, ref Main.mouseItem.favorited);
706 if (inv[slot].stack != inv[slot].maxStack && Main.mouseItem.stack != Main.mouseItem.maxStack)
707 {
708 if (Main.mouseItem.stack + inv[slot].stack <= Main.mouseItem.maxStack)
709 {
710 inv[slot].stack += Main.mouseItem.stack;
711 Main.mouseItem.stack = 0;
712 AnnounceTransfer(
new ItemTransferInfo(inv[slot], 21, context, inv[slot].stack));
713 }
714 else
715 {
716 int num2 = Main.mouseItem.maxStack - inv[slot].stack;
717 inv[slot].stack += num2;
718 Main.mouseItem.stack -= num2;
720 }
721 }
722 }
723 if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1)
724 {
725 Main.mouseItem =
new Item();
726 }
727 if (Main.mouseItem.type > 0 || inv[slot].type > 0)
728 {
729 Recipe.FindRecipes();
731 }
732 if (context == 3 && Main.netMode == 1)
733 {
734 NetMessage.SendData(32, -1, -1, null, player.chest, slot);
735 }
736 break;
737 case 1:
738 if (Main.mouseItem.stack == 1 && Main.mouseItem.type > 0 && inv[slot].type > 0 && inv[slot].IsNotTheSameAs(Main.mouseItem) && (context != 11 || Main.mouseItem.FitsAccessoryVanitySlot))
739 {
740 Utils.Swap(ref inv[slot], ref Main.mouseItem);
742 if (inv[slot].stack > 0)
743 {
744 switch (context)
745 {
746 case 0:
748 break;
749 case 8:
750 case 9:
751 case 10:
752 case 11:
753 case 12:
754 case 16:
755 case 17:
756 case 25:
757 case 27:
758 case 33:
760 break;
761 }
762 }
763 }
764 else if (Main.mouseItem.type == 0 && inv[slot].type > 0)
765 {
766 Utils.Swap(ref inv[slot], ref Main.mouseItem);
767 if (inv[slot].
type == 0 || inv[slot].stack < 1)
768 {
769 inv[slot] =
new Item();
770 }
771 if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1)
772 {
773 Main.mouseItem =
new Item();
774 }
775 if (Main.mouseItem.type > 0 || inv[slot].type > 0)
776 {
777 Recipe.FindRecipes();
779 }
780 }
781 else if (Main.mouseItem.type > 0 && inv[slot].type == 0 && (context != 11 || Main.mouseItem.FitsAccessoryVanitySlot))
782 {
783 if (Main.mouseItem.stack == 1)
784 {
785 Utils.Swap(ref inv[slot], ref Main.mouseItem);
786 if (inv[slot].
type == 0 || inv[slot].stack < 1)
787 {
788 inv[slot] =
new Item();
789 }
790 if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1)
791 {
792 Main.mouseItem =
new Item();
793 }
794 if (Main.mouseItem.type > 0 || inv[slot].type > 0)
795 {
796 Recipe.FindRecipes();
798 }
799 }
800 else
801 {
802 Main.mouseItem.stack--;
803 inv[slot].SetDefaults(Main.mouseItem.type);
804 Recipe.FindRecipes();
806 }
807 if (inv[slot].stack > 0)
808 {
809 switch (context)
810 {
811 case 0:
813 break;
814 case 8:
815 case 9:
816 case 10:
817 case 11:
818 case 12:
819 case 16:
820 case 17:
821 case 25:
822 case 27:
823 case 33:
825 break;
826 }
827 }
828 }
829 if ((context == 23 || context == 24) && Main.netMode == 1)
830 {
831 NetMessage.SendData(121, -1, -1, null, Main.myPlayer, player.tileEntityAnchor.interactEntityID, slot);
832 }
833 if (context == 26 && Main.netMode == 1)
834 {
835 NetMessage.SendData(124, -1, -1, null, Main.myPlayer, player.tileEntityAnchor.interactEntityID, slot);
836 }
837 break;
838 case 2:
839 if (Main.mouseItem.stack == 1 && Main.mouseItem.dye > 0 && inv[slot].type > 0 && inv[slot].type != Main.mouseItem.type)
840 {
841 Utils.Swap(ref inv[slot], ref Main.mouseItem);
843 if (inv[slot].stack > 0)
844 {
845 switch (context)
846 {
847 case 0:
849 break;
850 case 8:
851 case 9:
852 case 10:
853 case 11:
854 case 12:
855 case 16:
856 case 17:
857 case 25:
858 case 27:
859 case 33:
861 break;
862 }
863 }
864 }
865 else if (Main.mouseItem.type == 0 && inv[slot].type > 0)
866 {
867 Utils.Swap(ref inv[slot], ref Main.mouseItem);
868 if (inv[slot].
type == 0 || inv[slot].stack < 1)
869 {
870 inv[slot] =
new Item();
871 }
872 if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1)
873 {
874 Main.mouseItem =
new Item();
875 }
876 if (Main.mouseItem.type > 0 || inv[slot].type > 0)
877 {
878 Recipe.FindRecipes();
880 }
881 }
882 else if (Main.mouseItem.dye > 0 && inv[slot].type == 0)
883 {
884 if (Main.mouseItem.stack == 1)
885 {
886 Utils.Swap(ref inv[slot], ref Main.mouseItem);
887 if (inv[slot].
type == 0 || inv[slot].stack < 1)
888 {
889 inv[slot] =
new Item();
890 }
891 if (Main.mouseItem.type == 0 || Main.mouseItem.stack < 1)
892 {
893 Main.mouseItem =
new Item();
894 }
895 if (Main.mouseItem.type > 0 || inv[slot].type > 0)
896 {
897 Recipe.FindRecipes();
899 }
900 }
901 else
902 {
903 Main.mouseItem.stack--;
904 inv[slot].SetDefaults(Main.mouseItem.type);
905 Recipe.FindRecipes();
907 }
908 if (inv[slot].stack > 0)
909 {
910 switch (context)
911 {
912 case 0:
914 break;
915 case 8:
916 case 9:
917 case 10:
918 case 11:
919 case 12:
920 case 16:
921 case 17:
922 case 25:
923 case 27:
924 case 33:
926 break;
927 }
928 }
929 }
930 if (context == 25 && Main.netMode == 1)
931 {
932 NetMessage.SendData(121, -1, -1, null, Main.myPlayer, player.tileEntityAnchor.interactEntityID, slot, 1f);
933 }
934 if (context == 27 && Main.netMode == 1)
935 {
936 NetMessage.SendData(124, -1, -1, null, Main.myPlayer, player.tileEntityAnchor.interactEntityID, slot, 1f);
937 }
938 break;
939 case 3:
940 HandleShopSlot(inv, slot, rightClickIsValid: false, leftClickIsValid: true);
941 break;
942 case 4:
943 {
944 Chest chest = Main.instance.shop[Main.npcShop];
945 if (player.SellItem(Main.mouseItem))
946 {
947 chest.AddItemToShop(Main.mouseItem);
948 Main.mouseItem.SetDefaults();
951 }
952 else if (Main.mouseItem.value == 0)
953 {
954 chest.AddItemToShop(Main.mouseItem);
955 Main.mouseItem.SetDefaults();
958 }
959 Recipe.FindRecipes();
960 Main.stackSplit = 9999;
961 break;
962 }
963 case 5:
964 if (Main.mouseItem.IsAir)
965 {
967 Main.mouseItem.SetDefaults(inv[slot].netID);
968 Main.mouseItem.stack = Main.mouseItem.maxStack;
971 }
972 break;
973 }
974 if ((uint)context > 2u && context != 5 && context != 32)
975 {
976 inv[slot].favorited = false;
977 }
978 }
static void PlaySound(int type, Vector2 position, int style=1)
static void NotifyItemPickup(Player player, Item item)
static void HandleOnEquip(Player player, Item item, int context)
static bool OverrideLeftClick(Item[] inv, int context=0, int slot=0)
static void HandleShopSlot(Item[] inv, int slot, bool rightClickIsValid, bool leftClickIsValid)
static int PickItemMovementAction(Item[] inv, int context, int slot, Item checkItem)
static void AnnounceTransfer(ItemTransferInfo info)
static bool LeftClick_SellOrTrash(Item[] inv, int context, int slot)