Exemplo n.º 1
0
        public MetadataInts GetHotbar()
        {
            MetadataInts metadata = new MetadataInts();

            for (byte i = 0; i < ItemHotbar.Length; i++)
            {
                metadata[i] = new MetadataInt(ItemHotbar[i] + 9);
            }

            return(metadata);
        }
Exemplo n.º 2
0
        public MetadataInts ReadMetadataInts()
        {
            MetadataInts metadata = new MetadataInts();
            int          count    = ReadVarInt();

            for (byte i = 0; i < count; i++)
            {
                metadata[i] = new MetadataInt(ReadSignedVarInt());
            }

            return(metadata);
        }
Exemplo n.º 3
0
        public MetadataInts ReadMetadataInts()
        {
            MetadataInts metadata = new MetadataInts();
            short        count    = ReadShort();

            for (byte i = 0; i < count; i++)
            {
                metadata[i] = new MetadataInt(ReadInt());
            }

            return(metadata);
        }
Exemplo n.º 4
0
        public bool Import(byte[] data)
        {
            using (MemoryStream stream = new MemoryStream(data))
            {
                NbtBinaryReader reader = new NbtBinaryReader(stream, false);

                Armor      = MetadataSlots.FromStream(reader);
                Slots      = MetadataSlots.FromStream(reader);
                ItemHotbar = MetadataInts.FromStream(reader);
            }

            return(true);
        }
Exemplo n.º 5
0
        public PlayerInventory(Player player)
        {
            _player    = player;
            Armor      = new MetadataSlots();
            Slots      = new MetadataSlots();
            ItemHotbar = new MetadataInts();
            ItemInHand = new MetadataSlot(new ItemStack());

            Armor[0] = new MetadataSlot(new ItemStack());
            Armor[1] = new MetadataSlot(new ItemStack());
            Armor[2] = new MetadataSlot(new ItemStack());
            Armor[3] = new MetadataSlot(new ItemStack());

            //Armor[0] = new MetadataSlot(new ItemStack(306));
            //Armor[1] = new MetadataSlot(new ItemStack(307));
            //Armor[2] = new MetadataSlot(new ItemStack(308));
            //Armor[3] = new MetadataSlot(new ItemStack(309));

            for (byte i = 0; i < 35; i++)
            {
                Slots[i] = new MetadataSlot(new ItemStack((short)-1, 0));
            }

            byte c = 0;

            //Slots[c++] = new MetadataSlot(new ItemStack(383, 1, 34));
            //Slots[c++] = new MetadataSlot(new ItemStack(355, 64));
            Slots[c++] = new MetadataSlot(new ItemStack(261, 1));             // Bow
            Slots[c++] = new MetadataSlot(new ItemStack(262, 64));            // Arrows
            Slots[c++] = new MetadataSlot(new ItemStack(344, 64));            // Eggs
            Slots[c++] = new MetadataSlot(new ItemStack(332, 64));            // Snowballs
            //Slots[c++] = new MetadataSlot(new ItemStack(46, 64));
            //Slots[c++] = new MetadataSlot(new ItemStack(259, 1));
            Slots[c++] = new MetadataSlot(new ItemStack(268, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(280, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(290, 1));
            //Slots[c++] = new MetadataSlot(new ItemStack(259, 1)); // Flint/Steal
            //Slots[c++] = new MetadataSlot(new ItemStack(325, 64, 8)); // Water
            //Slots[c++] = new MetadataSlot(new ItemStack(325, 64, 10)); // Lava

            for (byte i = 0; i < 6; i++)
            {
                ItemHotbar[i] = new MetadataInt(i + 9);
            }
        }
Exemplo n.º 6
0
        public MetadataInts GetHotbar()
        {
            MetadataInts metadata = new MetadataInts();

            for (byte i = 0; i < ItemHotbar.Length; i++)
            {
                if (ItemHotbar[i] == -1)
                {
                    metadata[i] = new MetadataInt(-1);
                }
                else
                {
                    metadata[i] = new MetadataInt(ItemHotbar[i] + HotbarSize);
                }
            }

            return(metadata);
        }
Exemplo n.º 7
0
        public void Write(MetadataInts metadata)
        {
            if (metadata == null)
            {
                Write((short)0);
                return;
            }

            Write((short)metadata.Count);

            for (byte i = 0; i < metadata.Count; i++)
            {
                MetadataInt slot = metadata[i] as MetadataInt;
                if (slot != null)
                {
                    Write(slot.Value);
                }
            }
        }
Exemplo n.º 8
0
        public void Write(MetadataInts metadata)
        {
            if (metadata == null)
            {
                WriteVarInt(0);
                return;
            }

            WriteVarInt(metadata.Count);

            for (byte i = 0; i < metadata.Count; i++)
            {
                MetadataInt slot = metadata[i] as MetadataInt;
                if (slot != null)
                {
                    WriteSignedVarInt(slot.Value);
                }
            }
        }