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); } }
public void SendArmorForPlayer(Player receiver, Player player) { McpePlayerArmorEquipment mcpePlayerArmorEquipment = McpePlayerArmorEquipment.CreateObject(); mcpePlayerArmorEquipment.entityId = player.EntityId; mcpePlayerArmorEquipment.helmet = new MetadataSlot(new ItemStack(player.Inventory.Helmet, 0)); mcpePlayerArmorEquipment.chestplate = new MetadataSlot(new ItemStack(player.Inventory.Chest, 0)); mcpePlayerArmorEquipment.leggings = new MetadataSlot(new ItemStack(player.Inventory.Leggings, 0)); mcpePlayerArmorEquipment.boots = new MetadataSlot(new ItemStack(player.Inventory.Boots, 0)); receiver.SendPackage(mcpePlayerArmorEquipment); }
protected virtual void SendArmor() { 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); Level.RelayBroadcast(message); }
private void SendArmorForPlayer(Player player) { var armorEquipment = new McpePlayerArmorEquipment(); armorEquipment.entityId = player.EntityId; armorEquipment.helmet = new MetadataSlot(new ItemStack(player.Inventory.Helmet, 0)); armorEquipment.chestplate = new MetadataSlot(new ItemStack(player.Inventory.Chest, 0)); armorEquipment.leggings = new MetadataSlot(new ItemStack(player.Inventory.Leggings, 0)); armorEquipment.boots = new MetadataSlot(new ItemStack(player.Inventory.Boots, 0)); player.Level.RelayBroadcast(armorEquipment); }
public void SendArmorForPlayer(Player receiver, Player player) { McpePlayerArmorEquipment mcpePlayerArmorEquipment = McpePlayerArmorEquipment.CreateObject(); mcpePlayerArmorEquipment.entityId = player.EntityId; mcpePlayerArmorEquipment.helmet = (byte)(player.Inventory.Helmet.Id - 256); mcpePlayerArmorEquipment.chestplate = (byte)(player.Inventory.Chest.Id - 256); mcpePlayerArmorEquipment.leggings = (byte)(player.Inventory.Leggings.Id - 256); mcpePlayerArmorEquipment.boots = (byte)(player.Inventory.Boots.Id - 256); receiver.SendPackage(mcpePlayerArmorEquipment); }
protected virtual void SendArmor() { 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()); Level.RelayBroadcast(armorEquipment); }
private void SendArmorForPlayer(Player player) { var armorEquipment = new McpePlayerArmorEquipment(); armorEquipment.entityId = player.EntityId; armorEquipment.helmet = player.Inventory.Helmet; armorEquipment.chestplate = player.Inventory.Chest; armorEquipment.leggings = player.Inventory.Leggings; armorEquipment.boots = player.Inventory.Boots; player.Level.RelayBroadcast(armorEquipment); }
protected virtual void SendArmor() { 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(armorEquipment); }
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 armor equipment. /// </summary> /// <param name="message">The message.</param> private void HandlePlayerArmorEquipment(McpePlayerArmorEquipment message) { if (HealthManager.IsDead) { return; } McpePlayerArmorEquipment msg = McpePlayerArmorEquipment.CreateObject(); msg.entityId = EntityId; msg.helmet = message.helmet; msg.chestplate = message.chestplate; msg.leggings = message.leggings; msg.boots = message.boots; Level.RelayBroadcast(this, msg); }
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); } } }
protected virtual void HandlePlayerArmorEquipment(McpePlayerArmorEquipment message) { }
/// <summary> /// Handles the player armor equipment. /// </summary> /// <param name="message">The message.</param> protected virtual void HandlePlayerArmorEquipment(McpePlayerArmorEquipment message) { if (HealthManager.IsDead) return; McpePlayerArmorEquipment msg = McpePlayerArmorEquipment.CreateObject(); msg.entityId = EntityId; msg.helmet = message.helmet; msg.chestplate = message.chestplate; msg.leggings = message.leggings; msg.boots = message.boots; Level.RelayBroadcast(this, msg); }
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(); }