public override void SyncPlayer(int toWho, int fromWho, bool newPlayer)
        {
            ModPacket   packet    = mod.GetPacket();
            int         cnt       = 0;
            TagCompound research2 = new TagCompound();
            IEnumerator <KeyValuePair <string, object> > enume = research.GetEnumerator();

            enume.Reset();
            while (enume.MoveNext())
            {
                research2[enume.Current.Key] = research.GetAsInt(enume.Current.Key);
                cnt += (enume.Current.Key.ToByteArray().Length / 128) + 1;
                if (cnt >= 500)
                {
                    packet.Write((byte)0);
                    packet.Write((byte)player.whoAmI);
                    TagIO.Write(research2, packet);
                    packet.Send(toWho, fromWho);
                    cnt    = 0;
                    packet = mod.GetPacket();
                    research2.Clear();
                }
            }
            if (cnt > 0)
            {
                packet.Write((byte)0);
                packet.Write((byte)player.whoAmI);
                TagIO.Write(research2, packet);
                packet.Send(toWho, fromWho);
            }
            packet = mod.GetPacket();
            packet.Write((byte)1);
            packet.Write((byte)player.whoAmI);
            packet.Send(toWho, fromWho);
        }
Beispiel #2
0
        public void TestClear()
        {
            var tag = new TagCompound {
                ["key1"] = new List <byte>(),
                ["key2"] = 5
            };

            tag.Clear();
            Assert.AreEqual(tag.Count, 0);
            tag.Add("key1", 5);
            AssertEqual(tag, new TagCompound {
                { "key1", 5 }
            });
        }