Beispiel #1
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());

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

            byte c = 0;
            Slots[c++] = new MetadataSlot(new ItemStack(54, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(58, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(61, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(325, 1, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(173, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(263, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(268, 10));
            Slots[c++] = new MetadataSlot(new ItemStack(280, 10));

            for (byte i = 0; i < 6; i++)
            {
                ItemHotbar[i] = new MetadataInt(i + 9);
            }
            //ItemHotbar[0] = new MetadataInt(9);
        }
Beispiel #2
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, 1));
            //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);
            }
        }
Beispiel #3
0
		public static MetadataInts FromStream(BinaryReader stream)
		{
			var value = new MetadataInts();
			while (true)
			{
				byte key = stream.ReadByte();
				if (key == 127) break;

				byte type = (byte) ((key & 0xE0) >> 5);
				byte index = (byte) (key & 0x1F);

				var entry = EntryTypes[type]();
				entry.FromStream(stream);
				entry.Index = index;

				value[index] = entry;
			}
			return value;
		}
Beispiel #4
0
        public static MetadataInts FromStream(BinaryReader stream)
        {
            var value = new MetadataInts();

            while (true)
            {
                byte key = stream.ReadByte();
                if (key == 127)
                {
                    break;
                }

                byte type  = (byte)((key & 0xE0) >> 5);
                byte index = (byte)(key & 0x1F);

                var entry = EntryTypes[type]();
                entry.FromStream(stream);
                entry.Index = index;

                value[index] = entry;
            }
            return(value);
        }
Beispiel #5
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);
				}
			}
		}
Beispiel #6
0
        public MetadataInts GetHotbar()
        {
            MetadataInts metadata = new MetadataInts();
            for (byte i = 0; i < ItemHotbar.Length; i++)
            {
                metadata[i] = new MetadataInt(ItemHotbar[i] + HotbarSize);
            }

            return metadata;
        }