Exemplo n.º 1
0
        public void SendCraftingEvent()
        {
            var recipe = _recipeToSend;

            if (recipe != null)
            {
                {
                    McpeContainerSetSlot setSlot = new McpeContainerSetSlot();
                    setSlot.item     = new MetadataSlot(new ItemStack(new ItemBlock(new Block(17), 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 ItemBlock(new Block(17), 0), 1));
                    SendPackage(eq);
                }

                Log.Error("Sending crafting event: " + recipe.Id);

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

                {
                    MetadataSlots slotData = new MetadataSlots();
                    slotData[0]    = new MetadataSlot(new ItemStack(new ItemBlock(new Block(17), 0), 1));
                    crafting.input = slotData;
                }
                {
                    MetadataSlots slotData = new MetadataSlots();
                    slotData[0]     = new MetadataSlot(new ItemStack(new ItemBlock(new Block(5), 0), 4));
                    crafting.result = slotData;
                }

                SendPackage(crafting);

                //{
                //	McpeContainerSetSlot setSlot = new McpeContainerSetSlot();
                //	setSlot.item = new MetadataSlot(new ItemStack(new ItemBlock(new Block(5), 0), 4));
                //	setSlot.windowId = 0;
                //	setSlot.slot = 0;
                //	SendPackage(setSlot);
                //}

                {
                    McpePlayerEquipment eq = new McpePlayerEquipment();
                    eq.entityId     = _entityId;
                    eq.slot         = 10;
                    eq.selectedSlot = 1;
                    eq.item         = new MetadataSlot(new ItemStack(new ItemBlock(new Block(5), 0), 4));
                    SendPackage(eq);
                }
            }
        }
Exemplo n.º 2
0
 public Package onCraftingEvent(McpeCraftingEvent packet, Player player)
 {
     if (!Class1.lged.ContainsKey(player.Username.ToLower()))
     {
         notlogin(player);
         return(null);
     }
     return(packet);
 }
Exemplo n.º 3
0
 public void HandleMcpeCraftingEvent(McpeCraftingEvent message)
 {
 }
Exemplo n.º 4
0
		protected virtual void HandleCraftingEvent(McpeCraftingEvent message)
		{
			lock (Inventory)
			{
				Log.Info($"Player {Username} crafted item on window 0x{message.windowId:X2} on type: {message.recipeType} DatagramSequenceNumber: {message.DatagramSequenceNumber}, ReliableMessageNumber: {message.ReliableMessageNumber}, OrderingIndex: {message.OrderingIndex}");

				for (int i = 0; i < message.input.Count; i++)
				{
					MetadataSlot slot = (MetadataSlot) message.input[i];
					if (slot != null)
					{
						var itemStack = slot.Value;
						if (!VerifyItemStack(itemStack))
						{
							Log.Error($"Kicked {Username} for craft hacking.");
							Disconnect("Error #324. Please report this error.");
						}

						if (itemStack.Id == 0) continue;
						Log.Info($"Player {Username} craft input item ID: {itemStack.Id}, Meta: {itemStack.Metadata} Count: {itemStack.Count}");
						Inventory.RemoveItems(itemStack.Id, itemStack.Count);
					}
				}

				//for (int i = 0; i < message.result.Count; i++)
				//{
				//	MetadataSlot slot = (MetadataSlot) message.result[i];
				//	if (slot != null)
				//	{
				//		var itemStack = slot.Value;
				//		if (!VerifyItemStack(itemStack))
				//		{
				//			return;
				//		}

				//		if (!VerifyCraftingItemStack(this, itemStack))
				//		{
				//			return;
				//		}

				//		Log.Info($"Player {Username} craft output Item ID: {itemStack.Id} with count item count: {itemStack.Count}");
				//		Inventory.SetFirstEmptySlot(itemStack.Id, itemStack.Count, itemStack.Metadata, false, false);
				//	}
				//}

				//SendPlayerInventory();
			}
		}
Exemplo n.º 5
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);
            //}
        }
Exemplo n.º 6
0
        public void SendCraftingEvent()
        {
            var recipe = _recipeToSend;

            if (recipe != null)
            {
                {
                    McpeContainerSetSlot setSlot = new McpeContainerSetSlot();
                    setSlot.item = new ItemBlock(new Block(17), 0) {Count = 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 ItemBlock(new Block(17), 0) {Count = 1};
                    SendPackage(eq);
                }

                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 {new ItemBlock(new Block(17), 0) {Count = 1}};
                    crafting.input = slotData;
                }
                {
                    ItemStacks slotData = new ItemStacks {new ItemBlock(new Block(5), 0) {Count = 1}};
                    crafting.result = slotData;
                }

                SendPackage(crafting);

                //{
                //	McpeContainerSetSlot setSlot = new McpeContainerSetSlot();
                //	setSlot.item = new MetadataSlot(new ItemStack(new ItemBlock(new Block(5), 0), 4));
                //	setSlot.windowId = 0;
                //	setSlot.slot = 0;
                //	SendPackage(setSlot);
                //}

                {
                    McpePlayerEquipment eq = new McpePlayerEquipment();
                    eq.entityId = _entityId;
                    eq.slot = 10;
                    eq.selectedSlot = 1;
                    eq.item = new ItemBlock(new Block(5), 0) {Count = 1};
                    SendPackage(eq);
                }
            }
        }
 public abstract void HandleMcpeCraftingEvent(McpeCraftingEvent message);
Exemplo n.º 8
0
 public override void HandleMcpeCraftingEvent(McpeCraftingEvent message)
 {
 }
Exemplo n.º 9
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;

                {
                    var slotData = new MetadataSlots();
                    for (int i = 0; i < recipe.Input.Length; i++)
                    {
                        slotData[i] = new MetadataSlot(new ItemStack(recipe.Input[i], 1));

                        McpeContainerSetSlot setSlot = new McpeContainerSetSlot
                        {
                            item     = new MetadataSlot(new ItemStack(recipe.Input[i], 1)),
                            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         = new MetadataSlot(new ItemStack(recipe.Input[0], 1))
                        };
                        SendPackage(eq);
                        Log.Error("Set eq slot");
                    }
                }
                {
                    MetadataSlots slotData = new MetadataSlots();
                    slotData[0]     = new MetadataSlot(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);
            //}
        }
 public void HandleMcpeCraftingEvent(McpeCraftingEvent message)
 {
     WritePackage(message);
 }
Exemplo n.º 11
0
 public override void HandleMcpeCraftingEvent(McpeCraftingEvent message)
 {
     UnhandledPackage(message);
 }
Exemplo n.º 12
0
 public void HandleMcpeCraftingEvent(McpeCraftingEvent message)
 {
 }