コード例 #1
0
ファイル: InventoryUtils.cs プロジェクト: undrfined/MiNET
		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
ファイル: Package.cs プロジェクト: DarkSeraphim/MiNET
        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
ファイル: Inventory.cs プロジェクト: Rixium/Mayday
        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
ファイル: Inventory.cs プロジェクト: Jorch72/CS-MiNET
        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
ファイル: Inventory.cs プロジェクト: HungerBoatz/MiNET
        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
ファイル: Package.cs プロジェクト: qtx0213/MiNET
        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
ファイル: MiNetClient.cs プロジェクト: andrewhutche/MiNET
        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
ファイル: PlayerInventory.cs プロジェクト: CRBairdUSA/MiNET
        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
ファイル: InventoryUtils.cs プロジェクト: andrewhutche/MiNET
        public static ItemStacks GetCreativeMetadataSlots()
        {
            ItemStacks slotData = new ItemStacks();
            for (int i = 0; i < CreativeInventoryItems.Count; i++)
            {
                slotData.Add(CreativeInventoryItems[i]);
            }

            return slotData;
        }