Example #1
0
        public override void HandlePacket(BinaryReader reader, int whoAmI)
        {
            int messageID = reader.ReadByte();

            if (messageID == 0)
            {
                int player = reader.ReadByte();
                if (Main.netMode == NetmodeID.Server || player != Main.myPlayer)
                {
                    Main.player[player].GetModPlayer <PartsPlayer>().parts = TagIO.Read(reader);
                    return;
                }
            }
            if (messageID == 1)
            {
                int player = reader.ReadByte();
                int info   = reader.ReadInt32();
                if (Main.netMode == NetmodeID.Server || player != Main.myPlayer)
                {
                    PartsPlayer pl = Main.player[player].GetModPlayer <PartsPlayer>();
                    pl.ZoneFakeGranite    = ((info & 0x1) != 0);
                    pl.ZoneRealGranite    = ((info & 0x2) != 0);
                    pl.ZoneFakeMarble     = ((info & 0x4) != 0);
                    pl.ZoneRealMarble     = ((info & 0x8) != 0);
                    pl.ZoneFakeSpiderCave = ((info & 0x10) != 0);
                    pl.ZoneRealSpiderCave = ((info & 0x20) != 0);
                }
            }
        }
Example #2
0
        public bool DestroyPlayerItemForParts(Item itm)
        {
            PartsPlayer p = Main.player[Main.myPlayer].GetModPlayer <PartsPlayer>();

            if (tokenList.Contains(ItemToTag(itm)))
            {
                p.addPart(itm);
                p.destroyingItem = ui.destroySlot.item = new Item();
                return(true);
            }
            else if (ui.selectedRecipe != null)
            {
                ui.selectedRecipe.refund(p, ref p.destroyingItem);
                if (p.destroyingItem.stack <= 0)
                {
                    p.destroyingItem = ui.destroySlot.item = new Item();
                }
                return(true);
            }
            return(false);
        }