예제 #1
0
        public void UtilityMethods()
        {
            NbtTag[] testThings = new NbtTag[] {
                new NbtShort("Name1", 1),
                new NbtInt("Name2", 2),
                new NbtLong("Name3", 3)
            };
            NbtCompound compound = new NbtCompound();

            // add range
            compound.AddRange(testThings);

            // add range with duplicates
            Assert.Throws <ArgumentException>(() => compound.AddRange(testThings));
        }
예제 #2
0
        public NbtTag ToNBT()
        {
            NbtList Items = new NbtList("Items");

            foreach (KeyValuePair <byte, InventoryItem> p in this)
            {
                NbtCompound nc = new NbtCompound();
                nc.AddRange(new NbtTag[] {
                    new NbtByte("Count", (byte)p.Value.Count),
                    new NbtByte("Slot", p.Key),
                    new NbtShort("id", p.Value.ID),
                    new NbtShort("Damage", (short)p.Value.Damage)
                });
                Items.Add(nc);
            }
            return(Items);
        }
예제 #3
0
        public void UtilityMethods()
        {
            NbtTag[] testThings = new NbtTag[] {
                new NbtShort( "Name1", 1 ),
                new NbtInt( "Name2", 2 ),
                new NbtLong( "Name3", 3 )
            };
            NbtCompound compound = new NbtCompound();

            // add range
            compound.AddRange( testThings );

            // add range with duplicates
            Assert.Throws<ArgumentException>( () => compound.AddRange( testThings ) );
        }
예제 #4
0
        public NbtCompound Save()
        {
            NbtCompound rtn = new NbtCompound();

            rtn.Add(new NbtString("name", name));

            NbtList ground = new NbtList("ground", NbtTagType.Compound);
            NbtList portal = new NbtList("portal", NbtTagType.Compound);
            NbtList decor = new NbtList("decor", NbtTagType.Compound);
            foreach(Point alpha in map.Keys) {
                if(map[alpha] is Platform) {
                    ground.Add(new NbtCompound(new NbtByte[] {
                        new NbtByte("x", (byte)alpha.X),
                        new NbtByte("y", (byte)alpha.Y)
                    }));
                } else if(map[alpha] is Portal) {
                    portal.Add(new NbtCompound(new NbtTag[] {
                        new NbtByte("x", (byte)alpha.X),
                        new NbtByte("y", (byte)alpha.Y),
                        new NbtString("linkTo", ((Portal)map[alpha]).Link.MyArea.Name),
                        new NbtByte("linkX", (byte)((Portal)map[alpha]).Link.Location.X),
                        new NbtByte("linkY", (byte)((Portal)map[alpha]).Link.Location.Y)
                    }));
                }
            }

            rtn.AddRange(new NbtList[] { ground, portal, decor });

            return rtn;
        }