private void SendUpdateViewPosition(IMinecraftUser user) { // TODO: get chunk position according to current user's position. using var packet = new UpdateViewPositionPacket(0, 0); user.Send(packet); }
private void SendJoinGame(IMinecraftUser user) { using var joinPacket = new JoinGamePacket(); joinPacket.WriteInt32(user.Player.EntityId); // EntityID joinPacket.WriteBoolean(_gameConfiguration.Value.IsHardcore); // Is hardcore joinPacket.WriteByte((byte)_gameConfiguration.Value.Mode); // GameMode joinPacket.WriteSByte((sbyte)ServerGameModeType.Survival); // Previous game mode var worldList = new[] { "minecraft:world" }; joinPacket.WriteVarInt32(worldList.Length); // World count foreach (string world in worldList) { joinPacket.WriteString(world); } WriteDimensionsAndBiomes(_registry.Dimensions, _registry.Biomes, joinPacket); Dimension currentDimension = _registry.Dimensions.First(); WriteDimension(currentDimension, joinPacket); joinPacket.WriteString(currentDimension.Name); // World name identifier joinPacket.WriteInt64(_gameConfiguration.Value.Seed); // Seed joinPacket.WriteVarInt32((int)_serverConfiguration.Value.MaxPlayers); // Max players joinPacket.WriteVarInt32(Math.Clamp(_gameConfiguration.Value.RenderingDistance, RedstoneContants.MinimumRenderDistance, RedstoneContants.MaximumRenderDistance)); // Render distance (2-32 chunks) joinPacket.WriteBoolean(_serverConfiguration.Value.ReducedDebugInfo); // Reduced debug info joinPacket.WriteBoolean(_gameConfiguration.Value.DisplayRespawnScreen); // Respawn screen joinPacket.WriteBoolean(_serverConfiguration.Value.Debug); // Is debug joinPacket.WriteBoolean(_serverConfiguration.Value.FlatTerrain); // is flat terrain user.Send(joinPacket); }
public void OnPing(IMinecraftUser user, IMinecraftPacket packet) { var pingPacket = new StatusPingPacket(packet); using var pongPacket = new StatusPongPacket(pingPacket.Payload); user.Send(pongPacket); }
private void SendServerBrand(IMinecraftUser user) { using var serverBrandPacket = new PluginMessagePacket("minecraft:brand"); serverBrandPacket.WriteString(_serverConfiguration.Value.Name); user.Send(serverBrandPacket); }
private void SendLoginSucess(IMinecraftUser user) { using var p = new MinecraftPacket(ClientLoginPacketType.LoginSuccess); p.WriteUUID(user.Id); p.WriteString(user.Username); user.Send(p); }
private void SendChunkData(IMinecraftUser user) { IChunk chunk = _worldManager.Overworld.GetRegion(0, 0).GetChunk(0, 0); chunk.GenerateHeightMap(); // Temporary _worldManager.Overworld.AddPlayer(user.Player); using var packet = new ChunkDataPacket(chunk, serializeFullChunk: true); user.Send(packet); }
private void SendPlayerPositionAndLook(IMinecraftUser user, Position position) { using var packet = new PlayerPositionAndLookPacket(); packet.WriteDouble(position.X); // x packet.WriteDouble(position.Y); // y packet.WriteDouble(position.Z); // z packet.WriteSingle(0); // yaw packet.WriteSingle(0); // pitch packet.WriteByte(0); //packet.WriteByte(0x01 | 0x02 | 0x04); // position flags (x|y|z) packet.WriteVarInt32(0); // teleport id user.Send(packet); }
private void SendSpawnPosition(IMinecraftUser user, Position position) { using var packet = new SpawnPositionPacket(position); user.Send(packet); }
private void SendPlayerInfo(IMinecraftUser user, PlayerInfoActionType actionType) { using var packet = new PlayerInfoPacket(actionType, _server.ConnectedPlayers.Select(x => x.Player)); user.Send(packet); }
public void OnStatusRequest(IMinecraftUser user, IMinecraftPacket _) { using var responsePacket = new StatusResponsePacket(_server.GetServerStatus()); user.Send(responsePacket); }
public override void SendPacket(IMinecraftPacket packet) => _user.Send(packet);