obsidianmc / obsidian Goto Github PK
View Code? Open in Web Editor NEWA C# implementation of the Minecraft server protocol.
License: GNU General Public License v3.0
A C# implementation of the Minecraft server protocol.
License: GNU General Public License v3.0
Since IPluginClass.cs has ProjectUrl we should make use that in /plugins, therefore best place to put it in is to make each plugin item clickable.
In an effort to streamline and standardize DI, logging, and the lifetime of the bot, I would like to propose changing to a GenericHost.
Items to discuss:
Microsoft.Extensions.DependencyInjection
IHostApplicationLifetime.StopApplication()
to gracefully stop the bot as well as unblocking asynchronous runtimes). Works very well with systemd
's service management on the Linux side as well.IApplicationLifetime
and CancellationToken
sMicrosoft.Extensions.Logging
base (compatible with existing logging library).For those unfamiliar, the GenericHost is based off the WebHost
class from ASP.NET Core. However, this has the web-specific features removed in favor of a more generic long-lived service lifetime. The HostBuilder
provides a set of utilities for configuring the host, such as reading configuration items, setting up database connections, and registering services. The Obsidian server itself is registered as a BackgroundService which is responsible for handling startup (database migrations and so forth).
public override async Task ExecuteAsync(CancellationToken stoppingToken)
{
// Set up server
Console.WriteLine("Obsidian started successfully!");
stoppingToken.WaitHandle.WaitOne(); // Wait for a stop to be requested by the `IApplicationLifetime`.
Console.WriteLine("Obsidian shutting down...");
// Tear down
Console.WriteLine("Obsidian stopped.");
}
If we decide to move forward with this, I would be more than happy to be responsible for developing this and submitting a PR (or several).
Edit: I should point out that this will likely be a disruptive change since it involves redesigning the core of the bot as well as its lifetime management. However, I do believe that this will result in aiding future development and promote contributions by providing a well-known DI system.
Adding this feature was decided by a discord poll. Nullable annotation should be enabled in the whole solution.
Add sky light and block light arrays. These are present but commented out. Add the NBT tags to chunk section de/serialization.
REF: https://minecraft.gamepedia.com/Chunk_format
Adding this will allow the server and client to be version independent, making sure that packets will have the same outcome. (referencing the different id shifts and changes in https://wiki.vg/)
uh yeah can we stop using MinecraftStream.ToArray()?
Similarly to #18, it would be interesting to see a feature which brings support for forge mods as well, not just bukkit/spigot plugins.
Now while those are in most cases, direct modifications of the codebase, perhaps it would be possible to bring support for features like RefinedStorage.
I request this feature because of the implications of a C# server being capable of being optimized far more than java. Which would give better garbage collection, and therefore less memory usage.
Client crashes when sent a declaration of certain command. Command with no parameters (except for CommandContext
) works fine. Adding one int
parameter causes this behavior.
Reproduce by adding to MainCommandModule
:
[Command("oops")]
[CommandInfo("This should work, but doesn't!", "/oops <value>")]
public async Task OopsAsync(CommandContext context, int value)
{
}
minecraft:brand
("null" -> "obsidian" server branding in MC)Depends on #66.
https://wiki.vg/Protocol#Update_Light
After reviewing a large chunk of files, I've noticed that summary tags are not present to enable natural understanding and reduce the likelihood of open interpretation when working with objects, properties or methods. I would like to propose that summary tags be added to:
Additionally, if exceptions can be thrown from within methods or the get
/set
methods of properties then the appropriate exception tags should also be added.
At a minimum, these tags should be present, even if empty to consider this issue completed. This is because having the tags present will help encourage developers that have an understanding of the area they're working in, to add documentation for intellisense to pick up on. It also enables the ability to generate living documentation for the API project.
Depends on #62.
When a chunk is loaded with a load type 31 and below, entities should be ticked. Otherwise, entity ticking will stop.
Commands.TestCommandExec()
fails with an exception:
❌ Obsidian.Commands.Framework.Exceptions.InvalidCommandOverloadException : No such overload for command pong
It seems that command groups are not registered properly.
During playtesting, moving an item around inventory, an exception was thrown.
Player.GetHeldItem
can return null
, but the method's return type is not marked as nullable (even though Inventory.GetItem
which it wraps around has nullable return type). heldItem
being null
then causes an exception, as its properties are being accessed.
This should be an easy fix, but I would also like to note that we clearly haven't fully used the nullable notation and we should. Perhaps we could set nullable warnings as errors (<WarningsAsErrors>Nullable</WarningsAsErrors>
) to enforce null-safety? Related: #98
Builds generated by GitHub produce some warnings. these need to be fixed. Check the actions tab for output. Any xmldoc issues that nag about non-existant docs can be ignored for now.
This feature should be worked on after 1.12.2 has been implemented. Leaving this open for discussion etc.
https://minecraft.gamepedia.com/Player.dat_format
Saved in <worldname>/playerdata/ as <uuid>.dat.
Compatible w/ Minecraft player.dat files.
For a first round, serialize/deserialize gamemode (playerGameType), store spawn location.
Currently, if a plugin is unloaded, its dependencies are not informed. Unexpected or undocumented behavior may occur when attempting to interact with the unloaded plugin.
When a plugin unloads itself for whatever reason, all dependent plugins should be immediately informed so they may handle the situation as is appropriate.
An idea that might be interesting for plugins is adding support for interrupting packets.
My idea of how to implement such a thing:
events. We could have an event that the packet handler passes packets through before sending them, where plugins can choose to modify some values.
Original discussion from #82 (comment)
Commands will be able to be tagged with an IssuerScopeAttribute
attribute, which takes an enum of following values:
None
Command is basically disabled (probably remove this?)Client
Command sent by a playerConsole
Command typed into the native server consoleRemoteConsole
Command sent by remote console like RCONPlugin
Command executed by pluginAny
Flags of all values aboveBy default, if a command doesn't specify a scope, it will be able to be executed by any issuer (player, console, plugin).
To not force our opinions on what should be executable or not, the config should be able to configure what scopes commands have.
A checklist of packets that are yet to be implemented on master (ordered as on wiki.vg):
Clientbound
Serverbound
Login
Remove Newtonsoft.Json
dependency in favor of System.Text.Json
.
Windows hooks.
I was watching a FitMC video about jeb_ being griefed because some custom server indexer found the server he was playing on. This made me think it might be a good idea to add a "privacy" mode next to the whitelist, where the server will not return online player names after being queried.
Video in question:
https://www.youtube.com/watch?v=fvbVnT-RW-U
This is just an idea, but I think it might be nice to have. Maybe even a super private mode that wouldn't even return queried server info, whatever. I just think it would be nice and interesting. Let me know.
Provide a set of completions, warnings, fixes etc. for plugin developers working with Obsidian.API
. For certain code actions, making an extension might be needed (I don't think that analyzers can provide completion for example). This might need additional research and probably will be postponed until Obsidian.API
is complete and polished.
Currently we load assets at runtime upon server start. This could be changed so that assets are parsed at compile time and injected into code with a source generator. Startup would be faster and assets wouldn't be included in the build.
I've already tried to implement this, but there is an issue where System.Text.Json
is not found during compilation. There may be a workaround of having the dll
compiled and referenced directly in the project. Another consideration is using Newtonsoft.Json
, even though I tried to move away from it in favor of System.Text.Json
. However since it'd be used at compilation time, it wouldn't be a big problem.
Since I already have some experience with source generation, I will assign myself.
When instantiating objects and setting members simultaneously, it can be seen that there are two ways of doing this (sometimes in the same file:
var x = new Something() { Foo = 3 };
var y = new Something { Foo = 3 };
Both are perfectly acceptable, but mixing and matching should be avoided.
This is especially useful for automatically generating API Documentation.
Assigning myself, but any help is welcome.
Our codebase has entities stored with the region and tile entities stored in the chunk. Minecraft stores both in the chunk. Make a decision on how to proceed and implement.
https://github.com/ObsidianServer/Obsidian/blob/master/Obsidian/WorldData/Region.cs#L179
Depends on #62.
When a chunk is load type level 34 and above, the chunk should be flushed to disk and removed from memory.
As stated by @Seb-stian on Discord:
— Today at 4:26 PM
Roxxel's algorithm is great, but I would change the stuff around
[4:26 PM]
Right now it returns list of hit positions, which is not ideal for performance
[4:26 PM]
And also convenience in many cases
[4:27 PM]
But I will definitely include it at some point
Might be worth looking into it further.
In the future, it may be timeworthy to look into different GC settings. Server garbage collection in particular looks appealing. It should be significantly faster, but also consume more resources (great for dedicated servers?). Needs more research & runtime profiling (when Obsidian creates more garbage).
The new System.Text.Json source generator can
We can already use this feature via a NuGet package, but we may want to wait for .NET 6, where it gets shipped.
This issue depends on #121
Obsidian should randomize seeds when generating a new config. This should be a simple issue to fix.
The current console does not support user input. I don't think we'll ever implement this, because we run multiple servers on one console. A different option is implementing Minecraft's RCON protocol, so we can communicate with one specific server remotely.
Hacktoberfest edit: welcome! Feel free to tackle this issue if you feel like it. The RCON protocol would have to be it's own class that is able to accept connections and interact with the console in/output from Obsidian. Good luck!
In .NET 6, these new methods were added:
SinCos
ReciprocalEstimate
ReciprocalSqrtEstimate
We should identify places where these methods can be used and use them. For example Entity.GetLookDirection
.
Since GPL license is dissalows closed-source projects, GPL license may cause inconvenience for developers that make private projects, and this may affect on Obsidian's popularity. So, please, change Obsidian's license to MIT.
Networking can be made a lot faster and more clients can be handled. The idea is to use SocketAsyncEventArgs, pure TCP Socket and a custom lightweight buffered stream.
Resources:
https://github.com/chronoxor/NetCoreServer/blob/master/source/NetCoreServer/TcpServer.cs
https://www.codeproject.com/articles/83102/c-socketasynceventargs-high-performance-socket-cod
https://docs.microsoft.com/en-us/dotnet/api/system.net.sockets.socketasynceventargs?view=net-5.0#examples
https://github.com/ObsidianMC/Obsidian/blob/experimental/Obsidian/Net/NetWriteStream.cs
Assigning myself for now
Allow Obsidian plugins to have nuget dependencies. They should be correctly:
There might be a problem with versioning?
Currently the logger shows all messages, this will be annoying as end product of Obsidian, as future server maintainers won't find debug information useful.
Implement flow fields for entity pathfinding. There are some cases, where A* is not the best choice:
Flow fields can be of great benefit for us. Some things to consider:
For now, A* should do just fine, but I would like to see this implemented in the future.
Another discussion issue, discussing how we should write code.
The server uses a lot of memorystreams to convert data.
Perhaps its a good idea to dispose of these after they get used (to prevent memory leaking) as said by @Craftplacer
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.