Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #426 #428

Merged
merged 5 commits into from
Feb 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Obsidian.API/_Interfaces/IServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ public interface IServerConfiguration
/// </summary>
public RconConfig? Rcon { get; set; }

/// <summary>
/// The view distance of the server.
/// </summary>
/// <remarks>
/// Players with higher view distance will use the server's view distance.
/// </remarks>
public byte ViewDistance { get; set; }

public List<string> WhitelistedIPs { get; set; }
public List<WhitelistedPlayer> Whitelisted { get; set; }
}
2 changes: 1 addition & 1 deletion Obsidian/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ await QueuePacketAsync(new SynchronizePlayerPositionPacket
TeleportId = Player.TeleportId
});

await Player.UpdateChunksAsync(distance: 7);
await Player.UpdateChunksAsync(distance: server.Configuration.ViewDistance);
TheVeryStarlk marked this conversation as resolved.
Show resolved Hide resolved
await SendInfoAsync();
await this.server.EventDispatcher.ExecuteEventAsync(new PlayerJoinEventArgs(Player, this.server, DateTimeOffset.Now));
}
Expand Down
2 changes: 1 addition & 1 deletion Obsidian/Net/Packets/ClientInformationPacket.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public async ValueTask HandleAsync(Server server, Player player)
player.ClientInformation = new()
{
Locale = this.Locale,
ViewDistance = this.ViewDistance,
ViewDistance = sbyte.Min(ViewDistance, (sbyte) server.Configuration.ViewDistance),
ChatMode = this.ChatMode,
ChatColors = this.ChatColors,
DisplayedSkinParts = this.DisplayedSkinParts,
Expand Down
8 changes: 8 additions & 0 deletions Obsidian/Utilities/ServerConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,12 @@ public sealed class ServerConfiguration : IServerConfiguration

public bool AllowLan { get; set; } = true; // Enabled because it's super useful for debugging tbh

public byte ViewDistance
{
get => viewDistance;
set => viewDistance = value >= 3 ? value : viewDistance;
Naamloos marked this conversation as resolved.
Show resolved Hide resolved
}

public int PregenerateChunkRange { get; set; } = 15; // by default, pregenerate range from -15 to 15

[JsonConverter(typeof(JsonStringEnumConverter))]
Expand All @@ -64,6 +70,8 @@ public sealed class ServerConfiguration : IServerConfiguration
public ServerListQuery ServerListQuery { get; set; } = ServerListQuery.Full;

public int TimeTickSpeedMultiplier { get; set; } = 1;

private byte viewDistance = 10;
}

public sealed class ServerWorld
Expand Down
Loading