public override void HandleMcpeMobEquipment(McpeMobEquipment message) { if (Level is xCoreLevelLobby) { Item itemStack = message.item; if (GameMode != GameMode.Creative && itemStack != null && !VerifyItemStack(itemStack)) { Log.Error($"Kicked {Username} for equipment hacking."); Disconnect("Error #376. Please report this error."); } byte selectedHotbarSlot = message.selectedSlot; int selectedInventorySlot = (byte)(message.slot - PlayerInventory.HotbarSize); if (Log.IsDebugEnabled) { Log.Debug($"Player {Username} called set equiptment with inv slot: {selectedInventorySlot}({message.slot}) and hotbar slot {message.selectedSlot} with item {message.item}"); } // 255 indicates empty hmmm if (selectedInventorySlot < 0 || (message.slot != 255 && selectedInventorySlot >= Inventory.Slots.Count)) { if (GameMode != GameMode.Creative) { Log.Error($"Player {Username} set equiptment fails with inv slot: {selectedInventorySlot}({message.slot}) and hotbar slot {selectedHotbarSlot} for inventory size: {Inventory.Slots.Count} and Item ID: {message.item?.Id}"); } return; } if (message.slot == 255) { //Inventory.ItemHotbar[selectedHotbarSlot] = -1; //return; selectedInventorySlot = -1; } else { for (int i = 0; i < Inventory.ItemHotbar.Length; i++) { if (Inventory.ItemHotbar[i] == selectedInventorySlot) { Inventory.ItemHotbar[i] = Inventory.ItemHotbar[selectedHotbarSlot]; break; } } } Inventory.ItemHotbar[selectedHotbarSlot] = selectedInventorySlot; Inventory.InHandSlot = selectedHotbarSlot; //Inventory.SetHeldItemSlot(selectedHotbarSlot, false); } if (message.item.Id == Inventory.Slots[message.slot].Id) { if (message.item.Count == Inventory.Slots[message.slot].Count) { return; } } base.HandleMcpeMobEquipment(message); }
protected virtual void SendEquipment() { McpeMobEquipment message = McpeMobEquipment.CreateObject(); message.runtimeEntityId = EntityId; message.item = ItemInHand; message.slot = 0; Level.RelayBroadcast(message); }
private void SendEquipmentForPlayer(Player player) { var msg = McpeMobEquipment.CreateObject(); msg.runtimeEntityId = player.EntityId; msg.item = player.Inventory.GetItemInHand(); msg.slot = 0; player.Level.RelayBroadcast(msg); }
public static Action <Task, Item, int> DoMobEquipment(MiNetClient client) { Action <Task, Item, int> doMobEquipmentTask = (t, item, selectedSlot) => { McpeMobEquipment message = new McpeMobEquipment(); message.runtimeEntityId = client.EntityId; message.item = item; message.selectedSlot = (byte)selectedSlot; message.slot = (byte)(selectedSlot + 9); client.SendPackage(message); }; return(doMobEquipmentTask); }
public void SetSlot(Item i, int slot) { McpeContainerSetSlot sendSlot = McpeContainerSetSlot.CreateObject(); sendSlot.windowId = 0; sendSlot.slot = slot; sendSlot.item = i; SendPackage(sendSlot); McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = i; order.selectedSlot = (byte)slot; // Selected hotbar slot order.slot = (byte)slot; SendPackage(order); }
public void SendSetSlot(int slot) { if (slot < HotbarSize && (ItemHotbar[slot] == -1 || ItemHotbar[slot] == slot)) { ItemHotbar[slot] = slot /* + HotbarSize*/; Player.SendPlayerInventory(); McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = GetItemInHand(); order.selectedSlot = (byte)slot; // Selected hotbar slot Player.SendPackage(order); } else { McpeInventorySlot sendSlot = McpeInventorySlot.CreateObject(); sendSlot.inventoryId = 0; sendSlot.slot = slot; sendSlot.item = GetItemInHand(); Player.SendPackage(sendSlot); } }
public void SetHeldItemSlot(int selectedHotbarSlot, bool sendToPlayer = true) { InHandSlot = selectedHotbarSlot; if (sendToPlayer) { McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = GetItemInHand(); order.selectedSlot = (byte)selectedHotbarSlot; order.slot = (byte)ItemHotbar[InHandSlot]; Player.SendPackage(order); } McpeMobEquipment broadcast = McpeMobEquipment.CreateObject(); broadcast.runtimeEntityId = Player.EntityId; broadcast.item = GetItemInHand(); broadcast.selectedSlot = (byte)selectedHotbarSlot; broadcast.slot = (byte)ItemHotbar[InHandSlot]; Player.Level?.RelayBroadcast(Player, broadcast); }
public void SendSetSlot(int slot) { if (slot < HotbarSize && (ItemHotbar[slot] == -1 || ItemHotbar[slot] == slot)) { ItemHotbar[slot] = slot /* + HotbarSize*/; Player.SendPlayerInventory(); McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.entityId = 0; order.item = GetItemInHand(); order.selectedSlot = (byte)slot; // Selected hotbar slot Player.SendPackage(order); } else { McpeContainerSetSlot sendSlot = McpeContainerSetSlot.CreateObject(); sendSlot.windowId = 0; sendSlot.slot = (short)slot; sendSlot.item = Slots[slot]; Player.SendPackage(sendSlot); } }
public override void SetHeldItemSlot(int selectedHotbarSlot, bool sendToPlayer = true) { if (Player is SkyPlayer player) { if (player.IsGameSpectator && Player.Level is HubLevel) { InHandSlot = selectedHotbarSlot; //Don't send any changes to the player //This avoids the noticable 'flick' to the 0th slot that gets in the way if (sendToPlayer) { McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = GetItemInHand(); order.selectedSlot = (byte)selectedHotbarSlot; order.slot = (byte)(InHandSlot + HotbarSize); Player.SendPackage(order); } McpeMobEquipment broadcast = McpeMobEquipment.CreateObject(); broadcast.runtimeEntityId = Player.EntityId; broadcast.item = new ItemAir(); broadcast.selectedSlot = 0; broadcast.slot = (byte)(InHandSlot + HotbarSize); Player.Level?.RelayBroadcast(Player, broadcast); } else { base.SetHeldItemSlot(selectedHotbarSlot, sendToPlayer); } player.HandleHeldItemSlotChange(selectedHotbarSlot); } else { base.SetHeldItemSlot(selectedHotbarSlot, sendToPlayer); } }
public void SendSetSlot(int slot) { if (slot < 0 || slot > Slots.Length - 1) { return; } McpeInventorySlot ssendSlot = McpeInventorySlot.CreateObject(); ssendSlot.inventoryId = 0; ssendSlot.slot = slot; ssendSlot.item = Slots[slot]; Player.SendPackage(ssendSlot); return; if (slot < HotbarSize /* && (ItemHotbar[slot] == -1 || ItemHotbar[slot] == slot)*/) { // ItemHotbar[slot] = slot; //Player.SendPlayerInventory(); McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = Slots[slot]; order.slot = (byte)slot; order.selectedSlot = (byte)(slot); // Selected hotbar slot Player.SendPackage(order); } else { McpeInventorySlot sendSlot = McpeInventorySlot.CreateObject(); sendSlot.inventoryId = 0; sendSlot.slot = slot; sendSlot.item = Slots[slot]; Player.SendPackage(sendSlot); } }
public override void SpawnToPlayers(Player[] players) { { var fake = new Player(null, null) { ClientUuid = ClientUuid, EntityId = EntityId, NameTag = NameTag, DisplayName = NameTag, Username = NameTag, Skin = Skin, PlayerInfo = new PlayerInfo { DeviceOS = 7, PlatformChatId = NameTag, } }; var playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerAddRecords { fake }; Level.RelayBroadcast(players, Level.CreateMcpeBatch(playerList.Encode())); playerList.records = null; playerList.PutPool(); } { var message = McpeAddPlayer.CreateObject(); message.uuid = ClientUuid; message.username = NameTag; message.entityIdSelf = EntityId; message.runtimeEntityId = EntityId; message.x = KnownPosition.X; message.y = KnownPosition.Y; message.z = KnownPosition.Z; message.yaw = KnownPosition.Yaw; message.headYaw = KnownPosition.HeadYaw; message.pitch = KnownPosition.Pitch; message.metadata = GetMetadata(); message.userId = -1; Level.RelayBroadcast(players, message); } { var message = McpeMobEquipment.CreateObject(); message.runtimeEntityId = EntityId; message.item = ItemInHand; message.slot = 0; Level.RelayBroadcast(players, message); } { var armorEquipment = McpeMobArmorEquipment.CreateObject(); armorEquipment.runtimeEntityId = EntityId; armorEquipment.helmet = Helmet; armorEquipment.chestplate = Chest; armorEquipment.leggings = Leggings; armorEquipment.boots = Boots; Level.RelayBroadcast(players, armorEquipment); } { var fake = new Player(null, null) { ClientUuid = ClientUuid, EntityId = EntityId, NameTag = NameTag, Skin = Skin }; var playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerRemoveRecords { fake }; Level.RelayBroadcast(players, Level.CreateMcpeBatch(playerList.Encode())); playerList.records = null; playerList.PutPool(); } { var setEntityData = McpeSetEntityData.CreateObject(); setEntityData.runtimeEntityId = EntityId; setEntityData.metadata = GetMetadata(); Level?.RelayBroadcast(players, setEntityData); } }
public override void HandleMcpeContainerSetSlot(McpeContainerSetSlot message) { if (message.item.Id == Inventory.Slots[message.slot].Id) { if (message.item.Count == Inventory.Slots[message.slot].Count) { return; } } if (Level is xCoreLevel) { if (!(((xCoreLevel)Level).Status == Status.Start)) { base.HandleMcpeContainerSetSlot(message); } else { if (message.hotbarslot == 0) { McpeContainerSetContent strangeContent = McpeContainerSetContent.CreateObject(); strangeContent.windowId = (byte)0x7b; strangeContent.entityIdSelf = EntityId; strangeContent.slotData = new ItemStacks(); strangeContent.hotbarData = new MetadataInts(); SendPackage(strangeContent); McpeContainerSetContent inventoryContent = McpeContainerSetContent.CreateObject(); inventoryContent.windowId = (byte)0x00; inventoryContent.entityIdSelf = EntityId; inventoryContent.slotData = Inventory.GetSlots(); inventoryContent.hotbarData = Inventory.GetHotbar(); SendPackage(inventoryContent); McpeMobEquipment order = McpeMobEquipment.CreateObject(); order.runtimeEntityId = EntityManager.EntityIdSelf; order.item = message.item; order.selectedSlot = (byte)message.selectedSlot; // Selected hotbar slot order.slot = (byte)message.slot; SendPackage(order); //SendPlayerInventory(); } return; } } else { if (message.hotbarslot == 0) { McpeContainerSetContent strangeContent = McpeContainerSetContent.CreateObject(); strangeContent.windowId = (byte)0x7b; strangeContent.entityIdSelf = EntityId; strangeContent.slotData = new ItemStacks(); strangeContent.hotbarData = new MetadataInts(); SendPackage(strangeContent); McpeContainerSetContent inventoryContent = McpeContainerSetContent.CreateObject(); inventoryContent.windowId = (byte)0x00; inventoryContent.entityIdSelf = EntityId; inventoryContent.slotData = Inventory.GetSlots(); inventoryContent.hotbarData = Inventory.GetHotbar(); SendPackage(inventoryContent); } return; } base.HandleMcpeContainerSetSlot(message); }
public override void HandleMcpeMobEquipment(McpeMobEquipment message) { UnhandledPackage(message); }
public override void SpawnToPlayers(Player[] players) { { Player fake = new Player(null, null) { ClientUuid = Uuid, EntityId = EntityId, NameTag = NameTag, Skin = Skin }; McpePlayerList playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerAddRecords { fake }; Level.RelayBroadcast(players, Level.CreateMcpeBatch(playerList.Encode())); playerList.records = null; playerList.PutPool(); } { McpeAddPlayer message = McpeAddPlayer.CreateObject(); message.uuid = Uuid; message.username = NameTag; message.entityIdSelf = EntityId; message.runtimeEntityId = EntityId; message.x = KnownPosition.X; message.y = KnownPosition.Y; message.z = KnownPosition.Z; message.yaw = KnownPosition.Yaw; message.headYaw = KnownPosition.HeadYaw; message.pitch = KnownPosition.Pitch; message.metadata = GetMetadata(); Level.RelayBroadcast(players, message); } { McpeMobEquipment message = McpeMobEquipment.CreateObject(); message.runtimeEntityId = EntityId; message.item = ItemInHand; message.slot = 0; Level.RelayBroadcast(players, message); } { McpeMobArmorEquipment armorEquipment = McpeMobArmorEquipment.CreateObject(); armorEquipment.runtimeEntityId = EntityId; armorEquipment.helmet = ItemFactory.GetItem(Helmet); armorEquipment.chestplate = ItemFactory.GetItem(Chest); armorEquipment.leggings = ItemFactory.GetItem(Leggings); armorEquipment.boots = ItemFactory.GetItem(Boots); Level.RelayBroadcast(players, armorEquipment); } //{ // Player fake = new Player(null, null) // { // ClientUuid = Uuid, // EntityId = EntityId, // NameTag = NameTag, // Skin = Skin // }; // McpePlayerList playerList = McpePlayerList.CreateObject(); // playerList.records = new PlayerRemoveRecords {fake}; // Level.RelayBroadcast(players, Level.CreateMcpeBatch(playerList.Encode())); // playerList.records = null; // playerList.PutPool(); //} { McpeSetEntityData setEntityData = McpeSetEntityData.CreateObject(); setEntityData.runtimeEntityId = EntityId; setEntityData.metadata = GetMetadata(); Level?.RelayBroadcast(players, setEntityData); } }
public abstract void HandleMcpeMobEquipment(McpeMobEquipment message);
public override void HandleMcpeMobEquipment(McpeMobEquipment message) { }
public void HandleMcpeMobEquipment(McpeMobEquipment message) { WritePackage(message); }
public void HandleMcpeMobEquipment(McpeMobEquipment message) { }