Пример #1
0
		public static ItemStacks GetCreativeMetadataSlots()
		{
			ItemStacks slotData = new ItemStacks();
			for (int i = 0; i < CreativeInventoryItems.Count; i++)
			{
				slotData.Add(CreativeInventoryItems[i]);
			}

			return slotData;
		}
Пример #2
0
        public static ItemStacks ReadItemStacksAlternate(this Packet packet, bool networkIds)
        {
            ItemStacks itemStacks = new ItemStacks();
            uint       num        = packet.ReadUnsignedVarInt();

            for (int index = 0; (long)index < (long)num; ++index)
            {
                itemStacks.Add(packet.AlternativeReadItem(networkIds));
            }
            return(itemStacks);
        }
Пример #3
0
        public ItemStacks ReadItemStacks()
        {
            ItemStacks metadata = new ItemStacks();

            var count = ReadUnsignedVarInt();

            for (int i = 0; i < count; i++)
            {
                metadata.Add(ReadItem());
            }

            return(metadata);
        }
Пример #4
0
        public ItemStacks GetSlots()
        {
            ItemStacks slotData = new ItemStacks();

            for (int i = 0; i < Slots.Count; i++)
            {
                if (Slots[i].Count == 0)
                {
                    Slots[i] = new ItemAir();
                }
                slotData.Add(Slots[i]);
            }

            return(slotData);
        }
Пример #5
0
        public ItemStacks GetUiSlots()
        {
            ItemStacks slotData = new ItemStacks();

            for (int i = 0; i < UiInventory.Slots.Count; i++)
            {
                if (UiInventory.Slots[i].Count == 0)
                {
                    UiInventory.Slots[i] = new ItemAir();
                }
                slotData.Add(UiInventory.Slots[i]);
            }

            return(slotData);
        }
Пример #6
0
        private IItemStack CreateNewStackIfPossible()
        {
            if (ItemStacks == null)
            {
                ItemStacks = new List <IItemStack>();
            }

            if (ItemStacks.Count >= Slots)
            {
                return(null);
            }

            var newStack = new ItemStack();

            ItemStacks.Add(newStack);
            return(newStack);
        }
Пример #7
0
        public Inventory(int id, BlockEntity blockEntity, short inventorySize, NbtList slots)
        {
            Id          = id;
            BlockEntity = blockEntity;
            Size        = inventorySize;
            Coordinates = BlockEntity.Coordinates;

            Slots = new ItemStacks();
            for (byte i = 0; i < Size; i++)
            {
                Slots.Add(new ItemAir());
            }

            for (byte i = 0; i < slots.Count; i++)
            {
                NbtCompound item = (NbtCompound)slots[i];

                Slots[item["Slot"].ByteValue] = ItemFactory.GetItem(item["id"].ShortValue, item["Damage"].ShortValue, item["Count"].ByteValue);
            }
        }
Пример #8
0
        public Inventory(int id, BlockEntity blockEntity, short inventorySize, NbtList slots)
        {
            Id = id;
            BlockEntity = blockEntity;
            Size = inventorySize;
            Coordinates = BlockEntity.Coordinates;

            Slots = new ItemStacks();
            for (byte i = 0; i < Size; i++)
            {
                Slots.Add(new ItemStack());
            }

            for (byte i = 0; i < slots.Count; i++)
            {
                NbtCompound item = (NbtCompound) slots[i];

                Slots[item["Slot"].ByteValue] = new ItemStack(item["id"].ShortValue, item["Count"].ByteValue, item["Damage"].ByteValue);
            }
        }
Пример #9
0
        public ItemStacks ReadItemStacks()
        {
            int count;

            if (this is McpeCraftingEvent)
            {
                // Misaligned array counters for some packets :-(
                count = ReadInt();
            }
            else
            {
                count = ReadShort();
            }

            ItemStacks metadata = new ItemStacks();

            for (int i = 0; i < count; i++)
            {
                metadata.Add(ReadItem());
            }

            return(metadata);
        }
Пример #10
0
        public Inventory(int id, BlockEntity blockEntity, short inventorySize, NbtList slots)
        {
            Id          = id;
            BlockEntity = blockEntity;
            Size        = inventorySize;
            Coordinates = BlockEntity.Coordinates;

            Slots = new ItemStacks();
            for (byte i = 0; i < Size; i++)
            {
                Slots.Add(new ItemAir());
            }

            for (byte i = 0; i < slots.Count; i++)
            {
                var nbtItem = (NbtCompound)slots[i];

                Item item    = ItemFactory.GetItem(nbtItem["Name"].StringValue, nbtItem["Damage"].ShortValue, nbtItem["Count"].ByteValue);
                byte slotIdx = nbtItem["Slot"].ByteValue;
                Log.Debug($"Chest item {slotIdx}: {item}");
                Slots[slotIdx] = item;
            }
        }
Пример #11
0
        public void SendCraftingEvent2()
        {
            var recipe = _recipeToSend;

            if (recipe != null)
            {
                Log.Error("Sending crafting event: " + recipe.Id);

                McpeCraftingEvent crafting = new McpeCraftingEvent();
                crafting.windowId = 0;
                crafting.recipeType = 1;
                crafting.recipeId = recipe.Id;

                {
                    ItemStacks slotData = new ItemStacks();
                    for (int i = 0; i < recipe.Input.Length; i++)
                    {
                        slotData.Add(recipe.Input[i]);

                        McpeContainerSetSlot setSlot = new McpeContainerSetSlot
                        {
                            item = recipe.Input[i],
                            windowId = 0,
                            slot = (short) (i)
                        };
                        SendPackage(setSlot);
                        Log.Error("Set set slot");
                    }
                    crafting.input = slotData;

                    {
                        McpePlayerEquipment eq = new McpePlayerEquipment
                        {
                            entityId = _entityId,
                            slot = 9,
                            selectedSlot = 0,
                            item = recipe.Input[0]
                        };
                        SendPackage(eq);
                        Log.Error("Set eq slot");
                    }
                }
                {
                    ItemStacks slotData = new ItemStacks {recipe.Result};
                    crafting.result = slotData;
                }

                SendPackage(crafting);
            }

            //{
            //	McpeContainerSetSlot setSlot = new McpeContainerSetSlot();
            //	setSlot.item = new MetadataSlot(new ItemStack(new ItemDiamondAxe(0), 1));
            //	setSlot.windowId = 0;
            //	setSlot.slot = 0;
            //	SendPackage(setSlot);
            //}
            //{
            //	McpePlayerEquipment eq = new McpePlayerEquipment();
            //	eq.entityId = _entityId;
            //	eq.slot = 9;
            //	eq.selectedSlot = 0;
            //	eq.item = new MetadataSlot(new ItemStack(new ItemDiamondAxe(0), 1));
            //	SendPackage(eq);
            //}
        }
Пример #12
0
        public ItemStacks GetSlots()
        {
            ItemStacks slotData = new ItemStacks();
            for (int i = 0; i < Slots.Count; i++)
            {
                if (Slots[i].Count == 0) Slots[i] = new ItemAir();
                slotData.Add(Slots[i]);
            }

            return slotData;
        }
Пример #13
0
        public static ItemStacks GetCreativeMetadataSlots()
        {
            ItemStacks slotData = new ItemStacks();
            for (int i = 0; i < CreativeInventoryItems.Count; i++)
            {
                slotData.Add(CreativeInventoryItems[i]);
            }

            return slotData;
        }