Пример #1
0
        public void TestTypePromotions()
        {
            var tag = new TagCompound {
                ["byte1"]   = (byte)5,
                ["byte2"]   = (byte)254,
                ["short1"]  = (short)3200,
                ["short2"]  = (short)-3200,
                ["int1"]    = 0xFFEEFF,
                ["long1"]   = long.MaxValue,
                ["float1"]  = 1.25264f,
                ["float2"]  = float.MaxValue,
                ["float3"]  = float.NaN,
                ["double1"] = 1.25264
            };

            Assert.AreEqual(tag.GetAsShort("byte1"), (short)5);
            Assert.AreEqual(tag.GetAsShort("byte2"), (short)254);
            Assert.AreEqual(tag.GetAsShort("short2"), -3200);
            Assert.AreEqual(tag.GetAsInt("byte1"), 5);
            Assert.AreEqual(tag.GetAsInt("byte2"), 254);
            Assert.AreEqual(tag.GetAsInt("short1"), 3200);
            Assert.AreEqual(tag.GetAsInt("short2"), -3200);
            Assert.AreEqual(tag.GetAsInt("int1"), 0xFFEEFF);
            Assert.AreEqual(tag.GetAsLong("byte1"), 5);
            Assert.AreEqual(tag.GetAsLong("byte2"), 254);
            Assert.AreEqual(tag.GetAsLong("short1"), 3200);
            Assert.AreEqual(tag.GetAsLong("short2"), -3200);
            Assert.AreEqual(tag.GetAsLong("int1"), 0xFFEEFF);
            Assert.AreEqual(tag.GetAsLong("long1"), long.MaxValue);
            Assert.AreEqual(tag.GetAsDouble("float1"), 1.25264f);
            Assert.AreEqual(tag.GetAsDouble("float2"), float.MaxValue);
            Assert.AreEqual(tag.GetAsDouble("float3"), double.NaN);
            Assert.AreEqual(tag.GetAsDouble("double1"), 1.25264);
        }
Пример #2
0
 public override void Load(TagCompound tag)
 {
     itemList      = tag.GetIntArray(nameof(itemList));
     itemStackList = tag.GetIntArray(nameof(itemStackList));
     ChestType     = tag.GetAsShort(nameof(ChestType));
     ChestName     = tag.GetString(nameof(ChestName));
     inventorySpot = tag.GetAsInt(nameof(inventorySpot));
     firstTick     = tag.GetBool(nameof(firstTick));
     GotChest      = tag.GetBool(nameof(GotChest));
 }
Пример #3
0
        public override void LoadData(TagCompound tag)
        {
            if (tag.GetBool("initialized"))
            {
                level         = (ushort)tag.GetAsShort("level");
                currentXP     = (ulong)tag.GetAsLong("currentXP");
                neededXP      = CalculateNeededXP(level);
                statPoints    = (ushort)tag.GetAsShort("points");
                talents       = tag.Get <string>("talents");
                talentUnspent = (ushort)tag.GetAsShort("talentPoints");
                constitution  = (ushort)tag.GetAsShort("con");
                strength      = (ushort)tag.GetAsShort("str");
                intelligence  = (ushort)tag.GetAsShort("int");
                charisma      = (ushort)tag.GetAsShort("cha");
                dexterity     = (ushort)tag.GetAsShort("dex");
                mobility      = (ushort)tag.GetAsShort("mob");
                excavation    = (ushort)tag.GetAsShort("exc");
                animalia      = (ushort)tag.GetAsShort("ani");
                luck          = (ushort)(tag.ContainsKey("gra") ? tag.GetAsShort("gra") : tag.GetAsShort("luc"));
                mysticism     = (ushort)tag.GetAsShort("mys");

                if (currentXP > neededXP)
                {
                    LevelUp();
                }
            }
            else
            {
                initialize();
            }

            base.LoadData(tag);
        }
Пример #4
0
        public override void Load(TagCompound tag)
        {
            // cross compat. from 0.1.3
            if (tag.Any(x => x.Value is float))
            {
                if (tag.ContainsKey("amplitude"))
                {
                    amplitude = (double)tag.GetAsShort("amplitude");
                }
                if (tag.ContainsKey("speed"))
                {
                    speed = (double)tag.GetAsShort("speed");
                }
                if (tag.ContainsKey("universalOffset"))
                {
                    bounceOffset = (double)tag.GetAsShort("universalOffset");
                }
                if (tag.ContainsKey("bounceEvenly"))
                {
                    bounceEvenly = tag.Get <bool>("bounceEvenly");
                }
                if (tag.ContainsKey("disallowModItems"))
                {
                    bounceModItems = !tag.Get <bool>("disallowModItems");
                }
            }
            else
            {
                if (tag.ContainsKey("amplitude"))
                {
                    amplitude = tag.GetAsDouble("amplitude");
                }
                if (tag.ContainsKey("ampMult"))
                {
                    ampMult = tag.GetAsDouble("ampMult");
                }
                if (tag.ContainsKey("speed"))
                {
                    speed = tag.GetAsDouble("speed");
                }
                if (tag.ContainsKey("bounceOffset"))
                {
                    bounceOffset = tag.GetAsDouble("bounceOffset");
                }

                if (tag.ContainsKey("bounceEvenly"))
                {
                    bounceEvenly = tag.Get <bool>("bounceEvenly");
                }
                if (tag.ContainsKey("bounceModItems"))
                {
                    bounceModItems = tag.Get <bool>("bounceModItems");
                }
                if (tag.ContainsKey("byCosine"))
                {
                    byCosine = tag.Get <bool>("byCosine");
                }

                if (tag.ContainsKey("modVersion"))
                {
                    modVersion = ConstrucModversion(tag.GetString("modVersion"));
                }
            }

            if (tag.ContainsKey("bouncyItems"))
            {
                bouncyItems = new List <int>(tag.GetList <int>("bouncyItems"));
            }
        }