Exemplo n.º 1
0
        public async Task ReadSlot()
        {
            await SetupAsync();

            await using var stream = new MinecraftStream();

            var itemMeta = new ItemMetaBuilder()
                           .WithName("test")
                           .WithDurability(1)
                           .Build();

            var material = Material.Bedrock;

            var dataSlot = new ItemStack(material, 0, itemMeta)
            {
                Present = true
            };

            await stream.WriteSlotAsync(dataSlot);

            stream.Position = 0;

            var slot = await stream.ReadSlotAsync();

            Assert.True(slot.Present);
            Assert.Equal(0, slot.Count);
            Assert.Equal(material, slot.Type);

            Assert.Equal("test", slot.ItemMeta.Name.Text);
            Assert.Equal(1, slot.ItemMeta.Durability);
        }
Exemplo n.º 2
0
        public async Task ReadSlot()
        {
            await using var stream = new MinecraftStream();

            var dataSlot = new ItemStack
            {
                Count   = 0,
                Id      = 25,
                Present = true,
                Nbt     = new ItemNbt
                {
                    Slot   = 1,
                    Damage = 1
                }
            };

            await stream.WriteSlotAsync(dataSlot);

            stream.Position = 0;

            var slot = await stream.ReadSlotAsync();

            Assert.True(slot.Present);
            Assert.Equal(0, slot.Count);
            Assert.Equal(25, slot.Id);

            Assert.Equal(1, slot.Nbt.Slot);
            Assert.Equal(1, slot.Nbt.Damage);
        }
Exemplo n.º 3
0
        public async Task ReadAsync(MinecraftStream stream)
        {
            this.WindowId = await stream.ReadUnsignedByteAsync();

            this.ClickedSlot = await stream.ReadShortAsync();

            this.Button = await stream.ReadByteAsync();

            this.ActionNumber = await stream.ReadShortAsync();

            this.Mode = (InventoryOperationMode)await stream.ReadVarIntAsync();

            this.Item = await stream.ReadSlotAsync();
        }
Exemplo n.º 4
0
        public async Task ReadAsync(MinecraftStream stream)
        {
            this.ClickedSlot = await stream.ReadShortAsync();

            this.ClickedItem = await stream.ReadSlotAsync();
        }