public override void SpawnToPlayer(Player player) { { McpeAddPlayer message = McpeAddPlayer.CreateObject(); message.clientId = EntityId; message.username = NameTag ?? Name; message.entityId = 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.skin = Skin; message.metadata = GetMetadata().GetBytes(); player.SendPackage(message); } { McpePlayerEquipment message = McpePlayerEquipment.CreateObject(); message.entityId = EntityId; message.item = ItemInHand.Id; message.meta = ItemInHand.Metadata; message.slot = 0; player.SendPackage(message); } { McpePlayerArmorEquipment message = McpePlayerArmorEquipment.CreateObject(); message.entityId = EntityId; message.helmet = (byte)(Helmet - 256); message.chestplate = (byte)(Chest - 256); message.leggings = (byte)(Leggings - 256); message.boots = (byte)(Boots - 256); player.SendPackage(message); } }
private void SendEquipmentForPlayer(Player player) { var msg = McpePlayerEquipment.CreateObject(); msg.entityId = player.EntityId; msg.item = player.Inventory.GetItemInHand(); msg.slot = 0; player.Level.RelayBroadcast(msg); }
public void SendEquipmentForPlayer(Player receiver, Player player) { McpePlayerEquipment mcpePlayerEquipment = McpePlayerEquipment.CreateObject(); mcpePlayerEquipment.entityId = player.EntityId; mcpePlayerEquipment.item = new MetadataSlot(player.Inventory.GetItemInHand()); mcpePlayerEquipment.slot = 0; receiver.SendPackage(mcpePlayerEquipment); }
protected virtual void SendEquipment() { McpePlayerEquipment message = McpePlayerEquipment.CreateObject(); message.entityId = EntityId; message.item = ItemInHand; message.slot = 0; Level.RelayBroadcast(message); }
public void SetHeldItemSlotNoSend(int slot) { InHandSlot = slot; McpePlayerEquipment broadcast = McpePlayerEquipment.CreateObject(); broadcast.entityId = Player.EntityId; broadcast.item = GetItemInHand(); broadcast.selectedSlot = (byte)slot; Player.Level?.RelayBroadcast(broadcast); }
public void SetHeldItemSlot(int slot) { McpePlayerEquipment order = McpePlayerEquipment.CreateObject(); order.entityId = 0; order.selectedSlot = (byte)slot; Player.SendPackage(order); McpePlayerEquipment broadcast = McpePlayerEquipment.CreateObject(); broadcast.entityId = Player.EntityId; broadcast.selectedSlot = (byte)slot; Player.Level.RelayBroadcast(broadcast); }
public override void SpawnToPlayer(Player player) { { Player fake = new Player(null, null, 0) { ClientUuid = Uuid, EntityId = EntityId, NameTag = NameTag ?? Name, Skin = Skin }; McpePlayerList playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerAddRecords { fake }; player.SendPackage(playerList); //player.SendDirectPackage(playerList); } { McpeAddPlayer message = McpeAddPlayer.CreateObject(); message.uuid = Uuid; message.username = NameTag ?? Name; message.entityId = 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(); player.SendPackage(message); } { McpePlayerEquipment message = McpePlayerEquipment.CreateObject(); message.entityId = EntityId; message.item = ItemInHand; message.slot = 0; player.SendPackage(message); } { McpePlayerArmorEquipment armorEquipment = McpePlayerArmorEquipment.CreateObject(); armorEquipment.entityId = EntityId; armorEquipment.helmet = new MetadataSlot(new ItemStack()); armorEquipment.chestplate = new MetadataSlot(new ItemStack()); armorEquipment.leggings = new MetadataSlot(new ItemStack()); armorEquipment.boots = new MetadataSlot(new ItemStack()); player.SendPackage(armorEquipment); } }
/// <summary> /// Handles the player equipment. /// </summary> /// <param name="message">The message.</param> private void HandlePlayerEquipment(McpePlayerEquipment message) { if (HealthManager.IsDead) { return; } Inventory.ItemInHand.Value.Id = message.item; Inventory.ItemInHand.Value.Metadata = message.meta; McpePlayerEquipment msg = McpePlayerEquipment.CreateObject(); msg.entityId = EntityId; msg.item = message.item; msg.meta = message.meta; msg.slot = message.slot; msg.selectedSlot = message.selectedSlot; Level.RelayBroadcast(this, msg); }
public void SendSetSlot(int slot) { if (slot < HotbarSize && (ItemHotbar[slot] == -1 || ItemHotbar[slot] == slot)) { ItemHotbar[slot] = slot /* + HotbarSize*/; Player.SendPlayerInventory(); McpePlayerEquipment order = McpePlayerEquipment.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 void SetHeldItemSlot(int selectedHotbarSlot, bool sendToPlayer = true) { InHandSlot = selectedHotbarSlot; if (sendToPlayer) { McpePlayerEquipment order = McpePlayerEquipment.CreateObject(); order.entityId = 0; order.item = GetItemInHand(); order.selectedSlot = (byte)selectedHotbarSlot; order.slot = (byte)ItemHotbar[InHandSlot]; Player.SendPackage(order); } McpePlayerEquipment broadcast = McpePlayerEquipment.CreateObject(); broadcast.entityId = Player.EntityId; broadcast.item = GetItemInHand(); broadcast.selectedSlot = (byte)selectedHotbarSlot; broadcast.slot = (byte)ItemHotbar[InHandSlot]; Player.Level?.RelayBroadcast(broadcast); }
public void SpawnToAll(Player newPlayer) { lock (_playerWriteLock) { List <Player> spawnedPlayers = GetSpawnedPlayers().ToList(); spawnedPlayers.Add(newPlayer); Player[] sendList = spawnedPlayers.ToArray(); McpePlayerList playerListMessage = McpePlayerList.CreateObject(); playerListMessage.records = new PlayerAddRecords(spawnedPlayers); var bytes = playerListMessage.Encode(); playerListMessage.records = null; MemoryStream memStream = new MemoryStream(); memStream.Write(BitConverter.GetBytes(Endian.SwapInt32(bytes.Length)), 0, 4); memStream.Write(bytes, 0, bytes.Length); McpeBatch batch = McpeBatch.CreateObject(); byte[] buffer = Player.CompressBytes(memStream.ToArray(), CompressionLevel.Optimal); batch.payloadSize = buffer.Length; batch.payload = buffer; batch.Encode(); newPlayer.SendPackage(batch); McpePlayerList playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerAddRecords { newPlayer }; playerList.Encode(); playerList.records = null; RelayBroadcast(newPlayer, sendList, playerList); McpeAddPlayer mcpeAddPlayer = McpeAddPlayer.CreateObject(); mcpeAddPlayer.uuid = newPlayer.ClientUuid; mcpeAddPlayer.username = newPlayer.Username; mcpeAddPlayer.entityId = newPlayer.EntityId; mcpeAddPlayer.x = newPlayer.KnownPosition.X; mcpeAddPlayer.y = newPlayer.KnownPosition.Y; mcpeAddPlayer.z = newPlayer.KnownPosition.Z; mcpeAddPlayer.yaw = newPlayer.KnownPosition.Yaw; mcpeAddPlayer.headYaw = newPlayer.KnownPosition.HeadYaw; mcpeAddPlayer.pitch = newPlayer.KnownPosition.Pitch; mcpeAddPlayer.metadata = newPlayer.GetMetadata(); RelayBroadcast(newPlayer, sendList, mcpeAddPlayer); McpePlayerEquipment mcpePlayerEquipment = McpePlayerEquipment.CreateObject(); mcpePlayerEquipment.entityId = newPlayer.EntityId; mcpePlayerEquipment.item = new MetadataSlot(newPlayer.Inventory.GetItemInHand()); mcpePlayerEquipment.slot = 0; RelayBroadcast(newPlayer, sendList, mcpePlayerEquipment); McpePlayerArmorEquipment mcpePlayerArmorEquipment = McpePlayerArmorEquipment.CreateObject(); mcpePlayerArmorEquipment.entityId = newPlayer.EntityId; mcpePlayerArmorEquipment.helmet = new MetadataSlot(new ItemStack(newPlayer.Inventory.Helmet, 0)); mcpePlayerArmorEquipment.chestplate = new MetadataSlot(new ItemStack(newPlayer.Inventory.Chest, 0)); mcpePlayerArmorEquipment.leggings = new MetadataSlot(new ItemStack(newPlayer.Inventory.Leggings, 0)); mcpePlayerArmorEquipment.boots = new MetadataSlot(new ItemStack(newPlayer.Inventory.Boots, 0)); RelayBroadcast(newPlayer, sendList, mcpePlayerArmorEquipment); foreach (Player spawnedPlayer in spawnedPlayers) { SendAddForPlayer(newPlayer, spawnedPlayer, false); } } }
public override void SpawnToPlayers(Player[] players) { { Player fake = new Player(null, null) { ClientUuid = Uuid, EntityId = EntityId, NameTag = NameTag ?? Name, Skin = Skin }; McpePlayerList playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerAddRecords { fake }; Level.RelayBroadcast(players, playerList); } { McpeAddPlayer message = McpeAddPlayer.CreateObject(); message.uuid = Uuid; message.username = NameTag ?? Name; message.entityId = 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); } { McpePlayerEquipment message = McpePlayerEquipment.CreateObject(); message.entityId = EntityId; message.item = ItemInHand; message.slot = 0; Level.RelayBroadcast(players, message); } { McpePlayerArmorEquipment armorEquipment = McpePlayerArmorEquipment.CreateObject(); armorEquipment.entityId = 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 ?? Name, Skin = Skin }; McpePlayerList playerList = McpePlayerList.CreateObject(); playerList.records = new PlayerRemoveRecords { fake }; Level.RelayBroadcast(players, playerList); } // Probably not needed BroadcastSetEntityData(); }