MinecraftConnection 2.0.2
See the version list below for details.
dotnet add package MinecraftConnection --version 2.0.2
NuGet\Install-Package MinecraftConnection -Version 2.0.2
<PackageReference Include="MinecraftConnection" Version="2.0.2" />
paket add MinecraftConnection --version 2.0.2
#r "nuget: MinecraftConnection, 2.0.2"
// Install MinecraftConnection as a Cake Addin #addin nuget:?package=MinecraftConnection&version=2.0.2 // Install MinecraftConnection as a Cake Tool #tool nuget:?package=MinecraftConnection&version=2.0.2
MinecraftConnection
<div> <img src="https://raw.githubusercontent.com/takunology/MinecraftConnection/main/images/logo.png" width="300" hspace="0" vspace="10"> </div>
日本語版はこちら
MinecraftConnection is a library for sending commands via RCON using C# to help you learn and automate your programming. It can be run on a vanilla server as well as a Spigot server, including plugins. Before running the program, you need to start a Minecraft server that allows RCON connections.
1. Preparation
First, download the Minecraft Server software and run it in any game directory. A server configuration file called server.properties
will be created. Specify the password and port number for the RCON connection, and enable the connection.
Configuration example :
rcon.port=25575
rcon.password=minecraft
enable-rcon=true
After adding it save the file and restart the server. Launch Minecraft launcher and log in to the server. </br>
2. Create Project
This library is intended for .NET Standard 2.1
and above. This section describes how to create a .NET 6 console application.
Install MinecraftConnection
with the NuGet package manager, or run the following command in the package manager console.
Install-Package MinecraftConnection
Detail:https://www.nuget.org/packages/MinecraftConnection </br>
3. Sample programs
To run the program, start Minecraft Server and Minecraft itself (already logged in to the server). </br> Top-level statements are used here.
3.1 Set the time to 0
using MinecraftConnection;
// IP address or DNS name.
string address = "127.0.0.1";
ushort port = 25575;
string pass = "minecraft";
MinecraftCommands command = new MinecraftCommands(address, port, pass);
command.TimeSet(0);
</br>
3.2 Set off fireworks
using MinecraftConnection;
using MinecraftConnection.Entity;
string address = "127.0.0.1";
ushort port = 25575;
string pass = "minecraft";
MinecraftCommands command = new MinecraftCommands(address, port, pass);
// Define the coordinates at which you want to launch
Position pos = new Position(-516, 64, -205);
// Make a fireworks
Fireworks fireworks = new Fireworks()
{
LifeTime = 30, // Time to explosion
Type = FireworkType.LargeBall, // Fireworks type
Colors = FireworkOption.RandomColor(), // Fireworks color (RandomColor() is get random color)
FadeColors = new List<FireworkColors> { FireworkColors.WHITE }, // after explosion color
};
// Set off fireworks at defined position
command.SetOffFireworks(pos, fireworks);
Result :
<img src="https://raw.githubusercontent.com/takunology/MinecraftConnection/main/images/fireworks_sample.png" width="550" hspace="0" vspace="10">
Various fireworks can be set off depending on your ingenuity. If you would like to try it, please refer to this page.
https://zenn.dev/takunology/scraps/9462b03d13dd0a
3.3 Sorting items in a chest
You can retrieve items in a chest and sort them by ID or by count.</br>
The following source code allows you to sort items by name by using the SortById()
method on the retrieved item data. The MinecraftConnection.Extends
directive declaration is required to use the sorting method.
using MinecraftConnection;
using MinecraftConnection.Extends;
string address = "127.0.0.1";
ushort port = 25575;
string pass = "minecraft";
MinecraftCommands command = new MinecraftCommands(address, port, pass);
// Declare the coordinates of the "Chest block" or "Shulker box".
var pos = new Position(-502, 63, -213);
// Get the items in the chest.
var chestitems = command.GetChestItems(pos);
// Sort the acquired items and overwrite them in the chest again.
command.SetChestItems(pos, chestitems.SortByIdDescending());
Result:
<img src="https://raw.githubusercontent.com/takunology/MinecraftConnection/main/images/sort.gif" width="550" hspace="0" vspace="10">
4. Caution
The stop command is disabled due to the risk of stopping the server by RCON remote control. Executing the stop command in SendCommand method will raise an exception.
</br>
Project Detail: https://www.mcwithcode.com/
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- System.Text.Json (>= 6.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
2.1.0 | 940 | 8/25/2023 |
2.0.2 | 421 | 4/9/2023 |
2.0.1 | 692 | 8/20/2022 |
2.0.0 | 488 | 8/20/2022 |
2.0.0-preview1 | 313 | 6/6/2022 |
1.1.1 | 695 | 2/15/2022 |
1.1.0 | 524 | 8/10/2021 |
1.0.1 | 418 | 8/9/2021 |
1.0.0 | 418 | 8/3/2021 |
1.0.0-beta2 | 328 | 7/18/2021 |
1.0.0-beta1 | 380 | 6/29/2021 |
Version 2.0.2
- Fixed RandomColors() method in FireworkOption class
- Added SetBlock method overload