mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add submodule MinecraftProtocolLibrary
This commit is contained in:
parent
87026e1bfb
commit
3f1de66af3
62 changed files with 1093 additions and 450 deletions
3
.gitmodules
vendored
3
.gitmodules
vendored
|
|
@ -2,3 +2,6 @@
|
||||||
path = ConsoleInteractive
|
path = ConsoleInteractive
|
||||||
url = https://github.com/breadbyte/ConsoleInteractive
|
url = https://github.com/breadbyte/ConsoleInteractive
|
||||||
branch = main
|
branch = main
|
||||||
|
[submodule "MinecraftProtocolLibrary"]
|
||||||
|
path = MinecraftProtocolLibrary
|
||||||
|
url = https://github.com/BruceChenQAQ/Minecraft-Protocol-Library.git
|
||||||
|
|
|
||||||
|
|
@ -4,9 +4,14 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||||
VisualStudioVersion = 17.3.32901.215
|
VisualStudioVersion = 17.3.32901.215
|
||||||
MinimumVisualStudioVersion = 10.0.40219.1
|
MinimumVisualStudioVersion = 10.0.40219.1
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinecraftClient", "MinecraftClient\MinecraftClient.csproj", "{1E2FACE4-F5CA-4323-9641-740C6A551770}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinecraftClient", "MinecraftClient\MinecraftClient.csproj", "{1E2FACE4-F5CA-4323-9641-740C6A551770}"
|
||||||
|
ProjectSection(ProjectDependencies) = postProject
|
||||||
|
{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9} = {B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}
|
||||||
|
EndProjectSection
|
||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleInteractive", "ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive.csproj", "{93DA4D71-EFAD-4493-BE21-A105AF663660}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleInteractive", "ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive.csproj", "{93DA4D71-EFAD-4493-BE21-A105AF663660}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinecraftProtocolLibrary", "MinecraftProtocolLibrary\MinecraftProtocolLibrary\MinecraftProtocolLibrary.csproj", "{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
|
|
@ -21,13 +26,17 @@ Global
|
||||||
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Release|Any CPU.Build.0 = Release|Any CPU
|
{93DA4D71-EFAD-4493-BE21-A105AF663660}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||||
RESX_ShowErrorsInErrorList = False
|
|
||||||
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
|
|
||||||
RESX_SortFileContentOnSave = False
|
RESX_SortFileContentOnSave = False
|
||||||
|
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
|
||||||
|
RESX_ShowErrorsInErrorList = False
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
EndGlobal
|
EndGlobal
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Scripting;
|
using MinecraftClient.Scripting;
|
||||||
using Tomlet.Attributes;
|
using Tomlet.Attributes;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
||||||
using Brigadier.NET.Builder;
|
using Brigadier.NET.Builder;
|
||||||
using MinecraftClient.CommandHandler;
|
using MinecraftClient.CommandHandler;
|
||||||
using MinecraftClient.CommandHandler.Patch;
|
using MinecraftClient.CommandHandler.Patch;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
using MinecraftClient.Scripting;
|
using MinecraftClient.Scripting;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ using Brigadier.NET;
|
||||||
using Brigadier.NET.Builder;
|
using Brigadier.NET.Builder;
|
||||||
using MinecraftClient.CommandHandler;
|
using MinecraftClient.CommandHandler;
|
||||||
using MinecraftClient.CommandHandler.Patch;
|
using MinecraftClient.CommandHandler.Patch;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
using MinecraftClient.Scripting;
|
using MinecraftClient.Scripting;
|
||||||
using Tomlet.Attributes;
|
using Tomlet.Attributes;
|
||||||
|
|
|
||||||
|
|
@ -356,11 +356,12 @@ namespace MinecraftClient.ChatBots
|
||||||
|
|
||||||
for (int base_y = 0; base_y < map.Height; base_y += scale)
|
for (int base_y = 0; base_y < map.Height; base_y += scale)
|
||||||
{
|
{
|
||||||
int last_R = -1, last_G = -1, last_B = -1;
|
string lastFg = string.Empty, lagtBg = string.Empty;
|
||||||
for (int base_x = 0; base_x < map.Width; base_x += scale)
|
for (int base_x = 0; base_x < map.Width; base_x += scale)
|
||||||
{
|
{
|
||||||
int RL = 0, GL = 0, BL = 0, RR = 0, GR = 0, BR = 0;
|
int RUL = 0, GUL = 0, BUL = 0, RUR = 0, GUR = 0, BUR = 0;
|
||||||
double mid_dx = (double)(scale - 1) / 2;
|
int RDL = 0, GDL = 0, BDL = 0, RDR = 0, GDR = 0, BDR = 0;
|
||||||
|
double mid = (double)(scale - 1) / 2;
|
||||||
for (int dy = 0; dy < scale; ++dy)
|
for (int dy = 0; dy < scale; ++dy)
|
||||||
{
|
{
|
||||||
for (int dx = 0; dx < scale; ++dx)
|
for (int dx = 0; dx < scale; ++dx)
|
||||||
|
|
@ -368,40 +369,57 @@ namespace MinecraftClient.ChatBots
|
||||||
int x = Math.Min(base_x + dx, map.Width - 1);
|
int x = Math.Min(base_x + dx, map.Width - 1);
|
||||||
int y = Math.Min(base_y + dy, map.Height - 1);
|
int y = Math.Min(base_y + dy, map.Height - 1);
|
||||||
ColorRGBA color = MapColors.ColorByteToRGBA(map.Colors![x + y * map.Width]);
|
ColorRGBA color = MapColors.ColorByteToRGBA(map.Colors![x + y * map.Width]);
|
||||||
if (dx <= mid_dx)
|
if (dx <= mid)
|
||||||
{
|
{
|
||||||
RL += color.R; GL += color.G; BL += color.B;
|
if (dy <= mid)
|
||||||
|
{
|
||||||
|
RUL += color.R; GUL += color.G; BUL += color.B;
|
||||||
|
}
|
||||||
|
if (dy >= mid)
|
||||||
|
{
|
||||||
|
RDL += color.R; GDL += color.G; BDL += color.B;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (dx >= mid_dx)
|
if (dx >= mid)
|
||||||
{
|
{
|
||||||
RR += color.R; GR += color.G; BR += color.B;
|
if (dy <= mid)
|
||||||
|
{
|
||||||
|
RUR += color.R; GUR += color.G; BUR += color.B;
|
||||||
|
}
|
||||||
|
if (dy >= mid)
|
||||||
|
{
|
||||||
|
RDR += color.R; GDR += color.G; BDR += color.B;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int pixel_cnt = ((scale + 1) / 2) * scale;
|
int pixel_cnt = ((scale + 1) / 2) * ((scale + 1) / 2);
|
||||||
RL = (int)Math.Round((double)RL / pixel_cnt);
|
RDL = (int)Math.Round((double)RDL / pixel_cnt);
|
||||||
GL = (int)Math.Round((double)GL / pixel_cnt);
|
GDL = (int)Math.Round((double)GDL / pixel_cnt);
|
||||||
BL = (int)Math.Round((double)BL / pixel_cnt);
|
BDL = (int)Math.Round((double)BDL / pixel_cnt);
|
||||||
RR = (int)Math.Round((double)RR / pixel_cnt);
|
RDR = (int)Math.Round((double)RDR / pixel_cnt);
|
||||||
GR = (int)Math.Round((double)GR / pixel_cnt);
|
GDR = (int)Math.Round((double)GDR / pixel_cnt);
|
||||||
BR = (int)Math.Round((double)BR / pixel_cnt);
|
BDR = (int)Math.Round((double)BDR / pixel_cnt);
|
||||||
|
|
||||||
if (RL == last_R && GL == last_G && BL == last_B)
|
RUL = (int)Math.Round((double)RUL / pixel_cnt);
|
||||||
sb.Append(' ');
|
GUL = (int)Math.Round((double)GUL / pixel_cnt);
|
||||||
else
|
BUL = (int)Math.Round((double)BUL / pixel_cnt);
|
||||||
{
|
RUR = (int)Math.Round((double)RUR / pixel_cnt);
|
||||||
sb.Append(ColorHelper.GetColorEscapeCode((byte)RL, (byte)GL, (byte)BL, false)).Append(' ');
|
GUR = (int)Math.Round((double)GUR / pixel_cnt);
|
||||||
last_R = RL; last_G = GL; last_B = BL;
|
BUR = (int)Math.Round((double)BUR / pixel_cnt);
|
||||||
}
|
|
||||||
|
|
||||||
if (RR == last_R && GR == last_G && BR == last_B)
|
string colorCode = ColorHelper.GetColorEscapeCode((byte)RUL, (byte)GUL, (byte)BUL, true);
|
||||||
sb.Append(' ');
|
if (lastFg != colorCode) { sb.Append(colorCode); lastFg = colorCode; }
|
||||||
else
|
colorCode = ColorHelper.GetColorEscapeCode((byte)RDL, (byte)GDL, (byte)BDL, false);
|
||||||
{
|
if (lagtBg != colorCode) { sb.Append(colorCode); lagtBg = colorCode; }
|
||||||
sb.Append(ColorHelper.GetColorEscapeCode((byte)RR, (byte)GR, (byte)BR, false)).Append(' ');
|
sb.Append('▀');
|
||||||
last_R = RR; last_G = GR; last_B = BR;
|
|
||||||
}
|
colorCode = ColorHelper.GetColorEscapeCode((byte)RUR, (byte)GUR, (byte)BUR, true);
|
||||||
|
if (lastFg != colorCode) { sb.Append(colorCode); lastFg = colorCode; }
|
||||||
|
colorCode = ColorHelper.GetColorEscapeCode((byte)RDR, (byte)GDR, (byte)BDR, false);
|
||||||
|
if (lagtBg != colorCode) { sb.Append(colorCode); lagtBg = colorCode; }
|
||||||
|
sb.Append('▀');
|
||||||
}
|
}
|
||||||
if (base_y >= map.Height - scale)
|
if (base_y >= map.Height - scale)
|
||||||
sb.Append(ColorHelper.GetResetEscapeCode());
|
sb.Append(ColorHelper.GetResetEscapeCode());
|
||||||
|
|
|
||||||
|
|
@ -130,7 +130,7 @@ namespace MinecraftClient.ChatBots
|
||||||
//Load the given file from the startup parameters
|
//Load the given file from the startup parameters
|
||||||
if (LookForScript(ref file!))
|
if (LookForScript(ref file!))
|
||||||
{
|
{
|
||||||
lines = System.IO.File.ReadAllLines(file, Encoding.UTF8);
|
lines = File.ReadAllLines(file, Encoding.UTF8);
|
||||||
csharp = file.EndsWith(".cs");
|
csharp = file.EndsWith(".cs");
|
||||||
thread = null;
|
thread = null;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
using MinecraftClient.Scripting;
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MinecraftClient.Scripting;
|
||||||
|
|
||||||
namespace MinecraftClient.ChatBots
|
namespace MinecraftClient.ChatBots
|
||||||
{
|
{
|
||||||
|
|
@ -8,6 +10,19 @@ namespace MinecraftClient.ChatBots
|
||||||
|
|
||||||
public class TestBot : ChatBot
|
public class TestBot : ChatBot
|
||||||
{
|
{
|
||||||
|
//public override Tuple<McClientEventType, Func<object?, Task>>[]? InitializeEventCallbacks()
|
||||||
|
//{
|
||||||
|
// return new Tuple<McClientEventType, Func<object?, Task>>[]
|
||||||
|
// {
|
||||||
|
// new(McClientEventType.ClientTick, async (object? o) =>
|
||||||
|
// {
|
||||||
|
// await Task.CompletedTask;
|
||||||
|
// LogToConsole("test aaa");
|
||||||
|
// throw new Exception("dwadwa");
|
||||||
|
// })
|
||||||
|
// };
|
||||||
|
//}
|
||||||
|
|
||||||
public override void GetText(string text)
|
public override void GetText(string text)
|
||||||
{
|
{
|
||||||
string message = "";
|
string message = "";
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ using Brigadier.NET.ArgumentTypes;
|
||||||
using Brigadier.NET.Context;
|
using Brigadier.NET.Context;
|
||||||
using Brigadier.NET.Exceptions;
|
using Brigadier.NET.Exceptions;
|
||||||
using Brigadier.NET.Suggestion;
|
using Brigadier.NET.Suggestion;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.CommandHandler.ArgumentType
|
namespace MinecraftClient.CommandHandler.ArgumentType
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,14 +21,20 @@ namespace MinecraftClient.CommandHandler.ArgumentType
|
||||||
public override WindowActionType Parse(IStringReader reader)
|
public override WindowActionType Parse(IStringReader reader)
|
||||||
{
|
{
|
||||||
reader.SkipWhitespace();
|
reader.SkipWhitespace();
|
||||||
string inputStr = reader.ReadString();
|
string inputStr = reader.ReadString().ToLower();
|
||||||
foreach (var action in SupportActions)
|
return inputStr switch
|
||||||
{
|
{
|
||||||
string actionStr = action.ToString();
|
"left" => WindowActionType.LeftClick,
|
||||||
if (string.Compare(inputStr, actionStr, true) == 0)
|
"leftclick" => WindowActionType.LeftClick,
|
||||||
return action;
|
"right" => WindowActionType.RightClick,
|
||||||
}
|
"rightclick" => WindowActionType.RightClick,
|
||||||
throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr);
|
"mid" => WindowActionType.MiddleClick,
|
||||||
|
"middle" => WindowActionType.MiddleClick,
|
||||||
|
"middleclick" => WindowActionType.MiddleClick,
|
||||||
|
"shift" => WindowActionType.ShiftClick,
|
||||||
|
"shiftclick" => WindowActionType.ShiftClick,
|
||||||
|
_ => throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
|
public override Task<Suggestions> ListSuggestions<TSource>(CommandContext<TSource> context, SuggestionsBuilder builder)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ using Brigadier.NET;
|
||||||
using Brigadier.NET.ArgumentTypes;
|
using Brigadier.NET.ArgumentTypes;
|
||||||
using Brigadier.NET.Context;
|
using Brigadier.NET.Context;
|
||||||
using Brigadier.NET.Suggestion;
|
using Brigadier.NET.Suggestion;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.CommandHandler.ArgumentType
|
namespace MinecraftClient.CommandHandler.ArgumentType
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using Brigadier.NET.Context;
|
using Brigadier.NET.Context;
|
||||||
using MinecraftClient.CommandHandler.ArgumentType;
|
using MinecraftClient.CommandHandler.ArgumentType;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.CommandHandler
|
namespace MinecraftClient.CommandHandler
|
||||||
{
|
{
|
||||||
|
|
@ -31,9 +32,9 @@ namespace MinecraftClient.CommandHandler
|
||||||
return new EntityTypeArgumentType();
|
return new EntityTypeArgumentType();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Mapping.EntityType GetEntityType<TSource>(CommandContext<TSource> context, string name)
|
public static EntityType GetEntityType<TSource>(CommandContext<TSource> context, string name)
|
||||||
{
|
{
|
||||||
return context.GetArgument<Mapping.EntityType>(name);
|
return context.GetArgument<EntityType>(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemTypeArgumentType ItemType()
|
public static ItemTypeArgumentType ItemType()
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ namespace MinecraftClient.Commands
|
||||||
private static int DoAnimation(CmdResult r, bool mainhand)
|
private static int DoAnimation(CmdResult r, bool mainhand)
|
||||||
{
|
{
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
return r.SetAndReturn(handler.DoAnimation(mainhand ? 1 : 0).Result);
|
return r.SetAndReturn(handler.DoAnimationAsync(mainhand ? 1 : 0).Result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ namespace MinecraftClient.Commands
|
||||||
private static int DoLeaveBed(CmdResult r)
|
private static int DoLeaveBed(CmdResult r)
|
||||||
{
|
{
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
return r.SetAndReturn(Translations.cmd_bed_leaving, handler.SendEntityAction(Protocol.EntityActionType.LeaveBed).Result);
|
return r.SetAndReturn(Translations.cmd_bed_leaving, handler.SendEntityActionAsync(Protocol.EntityActionType.LeaveBed).Result);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int DoSleepBedWithRadius(CmdResult r, double radius)
|
private static int DoSleepBedWithRadius(CmdResult r, double radius)
|
||||||
|
|
@ -113,7 +113,7 @@ namespace MinecraftClient.Commands
|
||||||
return r.SetAndReturn(Status.FailChunkNotLoad,
|
return r.SetAndReturn(Status.FailChunkNotLoad,
|
||||||
string.Format(Translations.cmd_move_chunk_not_loaded, bedLocation.X, bedLocation.Y, bedLocation.Z));
|
string.Format(Translations.cmd_move_chunk_not_loaded, bedLocation.X, bedLocation.Y, bedLocation.Z));
|
||||||
|
|
||||||
if (handler.MoveTo(bedLocation))
|
if (handler.MoveToAsync(bedLocation).Result)
|
||||||
{
|
{
|
||||||
Task.Factory.StartNew(() =>
|
Task.Factory.StartNew(() =>
|
||||||
{
|
{
|
||||||
|
|
@ -137,7 +137,7 @@ namespace MinecraftClient.Commands
|
||||||
|
|
||||||
handler.Log.Info(string.Format(Translations.cmd_bed_moving, bedLocation.X, bedLocation.Y, bedLocation.Z));
|
handler.Log.Info(string.Format(Translations.cmd_bed_moving, bedLocation.X, bedLocation.Y, bedLocation.Z));
|
||||||
|
|
||||||
bool res = handler.PlaceBlock(bedLocation, Direction.Down).Result;
|
bool res = handler.PlaceBlockAsync(bedLocation, Direction.Down).Result;
|
||||||
|
|
||||||
handler.Log.Info(string.Format(
|
handler.Log.Info(string.Format(
|
||||||
Translations.cmd_bed_trying_to_use,
|
Translations.cmd_bed_trying_to_use,
|
||||||
|
|
@ -174,7 +174,7 @@ namespace MinecraftClient.Commands
|
||||||
blockCenter.X,
|
blockCenter.X,
|
||||||
blockCenter.Y,
|
blockCenter.Y,
|
||||||
blockCenter.Z,
|
blockCenter.Z,
|
||||||
handler.PlaceBlock(block, Direction.Down).Result ? Translations.cmd_bed_in : Translations.cmd_bed_not_in
|
handler.PlaceBlockAsync(block, Direction.Down).Result ? Translations.cmd_bed_in : Translations.cmd_bed_not_in
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -44,7 +44,7 @@ namespace MinecraftClient.Commands
|
||||||
if (!handler.GetInventoryEnabled())
|
if (!handler.GetInventoryEnabled())
|
||||||
return r.SetAndReturn(Status.FailNeedInventory);
|
return r.SetAndReturn(Status.FailNeedInventory);
|
||||||
|
|
||||||
if (handler.ChangeSlot((short)(slot - 1)).Result)
|
if (handler.ChangeSlotAsync((short)(slot - 1)).Result)
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_changeSlot_changed, slot));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_changeSlot_changed, slot));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(Status.Fail, Translations.cmd_changeSlot_fail);
|
return r.SetAndReturn(Status.Fail, Translations.cmd_changeSlot_fail);
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ namespace MinecraftClient.Commands
|
||||||
Block block = handler.GetWorld().GetBlock(blockToBreak);
|
Block block = handler.GetWorld().GetBlock(blockToBreak);
|
||||||
if (block.Type == Material.Air)
|
if (block.Type == Material.Air)
|
||||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
||||||
else if (handler.DigBlock(blockToBreak).Result)
|
else if (handler.DigBlockAsync(blockToBreak).Result)
|
||||||
{
|
{
|
||||||
blockToBreak = blockToBreak.ToCenter();
|
blockToBreak = blockToBreak.ToCenter();
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.GetTypeString()));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockToBreak.X, blockToBreak.Y, blockToBreak.Z, block.GetTypeString()));
|
||||||
|
|
@ -74,7 +74,7 @@ namespace MinecraftClient.Commands
|
||||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_too_far);
|
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_too_far);
|
||||||
else if (block.Type == Material.Air)
|
else if (block.Type == Material.Air)
|
||||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_no_block);
|
||||||
else if (handler.DigBlock(blockLoc, lookAtBlock: false).Result)
|
else if (handler.DigBlockAsync(blockLoc, lookAtBlock: false).Result)
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString()));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dig_dig, blockLoc.X, blockLoc.Y, blockLoc.Z, block.GetTypeString()));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_fail);
|
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_fail);
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ namespace MinecraftClient.Commands
|
||||||
var p = inventories[inventoryId];
|
var p = inventories[inventoryId];
|
||||||
int[] targetItems = p.SearchItem(itemType);
|
int[] targetItems = p.SearchItem(itemType);
|
||||||
foreach (int slot in targetItems)
|
foreach (int slot in targetItems)
|
||||||
handler.DoWindowAction(inventoryId, slot, WindowActionType.DropItemStack).Wait();
|
handler.DoWindowActionAsync(inventoryId, slot, WindowActionType.DropItemStack).Wait();
|
||||||
|
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dropItem_dropped, Item.GetTypeString(itemType), inventoryId));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_dropItem_dropped, Item.GetTypeString(itemType), inventoryId));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
||||||
using Brigadier.NET;
|
using Brigadier.NET;
|
||||||
using Brigadier.NET.Builder;
|
using Brigadier.NET.Builder;
|
||||||
using MinecraftClient.CommandHandler;
|
using MinecraftClient.CommandHandler;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
using static MinecraftClient.CommandHandler.CmdResult;
|
using static MinecraftClient.CommandHandler.CmdResult;
|
||||||
|
|
@ -166,12 +167,12 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
if (action == ActionType.Attack)
|
if (action == ActionType.Attack)
|
||||||
{
|
{
|
||||||
handler.InteractEntity(entity2.Key, InteractType.Attack).Wait();
|
handler.InteractEntityAsync(entity2.Key, InteractType.Attack).Wait();
|
||||||
actionst = Translations.cmd_entityCmd_attacked;
|
actionst = Translations.cmd_entityCmd_attacked;
|
||||||
}
|
}
|
||||||
else if (action == ActionType.Use)
|
else if (action == ActionType.Use)
|
||||||
{
|
{
|
||||||
handler.InteractEntity(entity2.Key, InteractType.Interact).Wait();
|
handler.InteractEntityAsync(entity2.Key, InteractType.Interact).Wait();
|
||||||
actionst = Translations.cmd_entityCmd_used;
|
actionst = Translations.cmd_entityCmd_used;
|
||||||
}
|
}
|
||||||
actioncount++;
|
actioncount++;
|
||||||
|
|
@ -251,7 +252,7 @@ namespace MinecraftClient.Commands
|
||||||
{
|
{
|
||||||
sb.Append($"\n [MCC] {Translations.cmd_entityCmd_latency}: {latency}");
|
sb.Append($"\n [MCC] {Translations.cmd_entityCmd_latency}: {latency}");
|
||||||
}
|
}
|
||||||
else if (type == EntityType.Item || type == EntityType.ItemFrame || type == Mapping.EntityType.EyeOfEnder || type == Mapping.EntityType.Egg || type == Mapping.EntityType.EnderPearl || type == Mapping.EntityType.Potion || type == Mapping.EntityType.Fireball || type == Mapping.EntityType.FireworkRocket)
|
else if (type == EntityType.Item || type == EntityType.ItemFrame || type == EntityType.EyeOfEnder || type == EntityType.Egg || type == EntityType.EnderPearl || type == EntityType.Potion || type == EntityType.Fireball || type == EntityType.FireworkRocket)
|
||||||
{
|
{
|
||||||
string? displayName = item.DisplayName;
|
string? displayName = item.DisplayName;
|
||||||
if (string.IsNullOrEmpty(displayName))
|
if (string.IsNullOrEmpty(displayName))
|
||||||
|
|
@ -311,10 +312,10 @@ namespace MinecraftClient.Commands
|
||||||
switch (action)
|
switch (action)
|
||||||
{
|
{
|
||||||
case ActionType.Attack:
|
case ActionType.Attack:
|
||||||
handler.InteractEntity(entity.ID, InteractType.Attack).Wait();
|
handler.InteractEntityAsync(entity.ID, InteractType.Attack).Wait();
|
||||||
return Translations.cmd_entityCmd_attacked;
|
return Translations.cmd_entityCmd_attacked;
|
||||||
case ActionType.Use:
|
case ActionType.Use:
|
||||||
handler.InteractEntity(entity.ID, InteractType.Interact).Wait();
|
handler.InteractEntityAsync(entity.ID, InteractType.Interact).Wait();
|
||||||
return Translations.cmd_entityCmd_used;
|
return Translations.cmd_entityCmd_used;
|
||||||
case ActionType.List:
|
case ActionType.List:
|
||||||
return GetEntityInfoDetailed(handler, entity);
|
return GetEntityInfoDetailed(handler, entity);
|
||||||
|
|
|
||||||
|
|
@ -159,7 +159,7 @@ namespace MinecraftClient.Commands
|
||||||
|
|
||||||
if (handler.GetGamemode() == 1)
|
if (handler.GetGamemode() == 1)
|
||||||
{
|
{
|
||||||
if (handler.DoCreativeGive(slot, itemType, count, null).Result)
|
if (handler.DoCreativeGiveAsync(slot, itemType, count, null).Result)
|
||||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_done, itemType, count, slot));
|
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_done, itemType, count, slot));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
||||||
|
|
@ -178,7 +178,7 @@ namespace MinecraftClient.Commands
|
||||||
|
|
||||||
if (handler.GetGamemode() == 1)
|
if (handler.GetGamemode() == 1)
|
||||||
{
|
{
|
||||||
if (handler.DoCreativeGive(slot, ItemType.Null, 0, null).Result)
|
if (handler.DoCreativeGiveAsync(slot, ItemType.Null, 0, null).Result)
|
||||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_delete, slot));
|
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_creative_delete, slot));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
||||||
|
|
@ -279,7 +279,7 @@ namespace MinecraftClient.Commands
|
||||||
if (inventory == null)
|
if (inventory == null)
|
||||||
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
|
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_not_exist, inventoryId));
|
||||||
|
|
||||||
if (handler.CloseInventory(inventoryId.Value).Result)
|
if (handler.CloseInventoryAsync(inventoryId.Value).Result)
|
||||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_close, inventoryId));
|
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_close, inventoryId));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_close_fail, inventoryId));
|
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_close_fail, inventoryId));
|
||||||
|
|
@ -355,7 +355,7 @@ namespace MinecraftClient.Commands
|
||||||
};
|
};
|
||||||
|
|
||||||
handler.Log.Info(string.Format(Translations.cmd_inventory_clicking, keyName, slot, inventoryId));
|
handler.Log.Info(string.Format(Translations.cmd_inventory_clicking, keyName, slot, inventoryId));
|
||||||
var task = handler.DoWindowAction(inventoryId.Value, slot, actionType);
|
var task = handler.DoWindowActionAsync(inventoryId.Value, slot, actionType);
|
||||||
task.Wait();
|
task.Wait();
|
||||||
return r.SetAndReturn(task.Result);
|
return r.SetAndReturn(task.Result);
|
||||||
}
|
}
|
||||||
|
|
@ -381,7 +381,7 @@ namespace MinecraftClient.Commands
|
||||||
if (!inventory.Items.ContainsKey(slot))
|
if (!inventory.Items.ContainsKey(slot))
|
||||||
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_no_item, slot));
|
return r.SetAndReturn(CmdResult.Status.Fail, string.Format(Translations.cmd_inventory_no_item, slot));
|
||||||
|
|
||||||
if (handler.DoWindowAction(inventoryId.Value, slot, actionType).Result)
|
if (handler.DoWindowActionAsync(inventoryId.Value, slot, actionType).Result)
|
||||||
{
|
{
|
||||||
if (actionType == WindowActionType.DropItemStack)
|
if (actionType == WindowActionType.DropItemStack)
|
||||||
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_drop_stack, slot));
|
return r.SetAndReturn(CmdResult.Status.Done, string.Format(Translations.cmd_inventory_drop_stack, slot));
|
||||||
|
|
|
||||||
|
|
@ -145,7 +145,7 @@ namespace MinecraftClient.Commands
|
||||||
|
|
||||||
Location current = handler.GetCurrentLocation();
|
Location current = handler.GetCurrentLocation();
|
||||||
Location currentCenter = new(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
|
Location currentCenter = new(Math.Floor(current.X) + 0.5, current.Y, Math.Floor(current.Z) + 0.5);
|
||||||
handler.MoveTo(currentCenter, allowDirectTeleport: true);
|
handler.MoveToAsync(currentCenter, allowDirectTeleport: true).Wait();
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_walk, currentCenter, current));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_walk, currentCenter, current));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ namespace MinecraftClient.Commands
|
||||||
|
|
||||||
if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction))
|
if (Movement.CanMove(handler.GetWorld(), handler.GetCurrentLocation(), direction))
|
||||||
{
|
{
|
||||||
if (handler.MoveTo(goal, allowUnsafe: takeRisk))
|
if (handler.MoveToAsync(goal, allowUnsafe: takeRisk).Result)
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_moving, direction.ToString()));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_moving, direction.ToString()));
|
||||||
else
|
else
|
||||||
return r.SetAndReturn(Status.Fail, takeRisk ? Translations.cmd_move_dir_fail : Translations.cmd_move_suggestforce);
|
return r.SetAndReturn(Status.Fail, takeRisk ? Translations.cmd_move_dir_fail : Translations.cmd_move_suggestforce);
|
||||||
|
|
@ -188,8 +188,8 @@ namespace MinecraftClient.Commands
|
||||||
if (takeRisk || Movement.PlayerFitsHere(handler.GetWorld(), goal))
|
if (takeRisk || Movement.PlayerFitsHere(handler.GetWorld(), goal))
|
||||||
{
|
{
|
||||||
if (current.ToFloor() == goal.ToFloor())
|
if (current.ToFloor() == goal.ToFloor())
|
||||||
handler.MoveTo(goal, allowDirectTeleport: true);
|
handler.MoveToAsync(goal, allowDirectTeleport: true).Wait();
|
||||||
else if (!handler.MoveTo(goal, allowUnsafe: takeRisk))
|
else if (!handler.MoveToAsync(goal, allowUnsafe: takeRisk).Result)
|
||||||
return r.SetAndReturn(Status.Fail, takeRisk ? string.Format(Translations.cmd_move_fail, goal) : string.Format(Translations.cmd_move_suggestforce, goal));
|
return r.SetAndReturn(Status.Fail, takeRisk ? string.Format(Translations.cmd_move_fail, goal) : string.Format(Translations.cmd_move_suggestforce, goal));
|
||||||
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_walk, goal, current));
|
return r.SetAndReturn(Status.Done, string.Format(Translations.cmd_move_walk, goal, current));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,7 @@ namespace MinecraftClient.Commands
|
||||||
private int DoRespawn(CmdResult r)
|
private int DoRespawn(CmdResult r)
|
||||||
{
|
{
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
handler.SendRespawnPacket().Wait();
|
handler.SendRespawnPacketAsync().Wait();
|
||||||
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_respawn_done);
|
return r.SetAndReturn(CmdResult.Status.Done, Translations.cmd_respawn_done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,7 +41,7 @@ namespace MinecraftClient.Commands
|
||||||
private int DoExecuteScript(CmdResult r, string command, Dictionary<string, object>? localVars)
|
private int DoExecuteScript(CmdResult r, string command, Dictionary<string, object>? localVars)
|
||||||
{
|
{
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
handler.BotLoad(new ChatBots.Script(command.Trim(), null, localVars));
|
handler.BotLoad(new ChatBots.Script(command.Trim(), null, localVars)).Wait();
|
||||||
return r.SetAndReturn(CmdResult.Status.Done);
|
return r.SetAndReturn(CmdResult.Status.Done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ namespace MinecraftClient.Commands
|
||||||
private int DoSendText(CmdResult r, string command)
|
private int DoSendText(CmdResult r, string command)
|
||||||
{
|
{
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
handler.SendText(command).Wait();
|
handler.SendTextAsync(command).Wait();
|
||||||
return r.SetAndReturn(CmdResult.Status.Done);
|
return r.SetAndReturn(CmdResult.Status.Done);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,7 @@ namespace MinecraftClient.Commands
|
||||||
McClient handler = CmdResult.currentHandler!;
|
McClient handler = CmdResult.currentHandler!;
|
||||||
if (sneaking)
|
if (sneaking)
|
||||||
{
|
{
|
||||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking).Result;
|
var result = handler.SendEntityActionAsync(Protocol.EntityActionType.StopSneaking).Result;
|
||||||
if (result)
|
if (result)
|
||||||
sneaking = false;
|
sneaking = false;
|
||||||
if (result)
|
if (result)
|
||||||
|
|
@ -52,7 +52,7 @@ namespace MinecraftClient.Commands
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StartSneaking).Result;
|
var result = handler.SendEntityActionAsync(Protocol.EntityActionType.StartSneaking).Result;
|
||||||
if (result)
|
if (result)
|
||||||
sneaking = true;
|
sneaking = true;
|
||||||
if (result)
|
if (result)
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ namespace MinecraftClient.Commands
|
||||||
if (!handler.GetInventoryEnabled())
|
if (!handler.GetInventoryEnabled())
|
||||||
return r.SetAndReturn(Status.FailNeedInventory);
|
return r.SetAndReturn(Status.FailNeedInventory);
|
||||||
|
|
||||||
handler.UseItemOnHand().Wait();
|
handler.UseItemOnHandAsync().Wait();
|
||||||
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -48,7 +48,7 @@ namespace MinecraftClient.Commands
|
||||||
Location current = handler.GetCurrentLocation();
|
Location current = handler.GetCurrentLocation();
|
||||||
block = block.ToAbsolute(current).ToFloor();
|
block = block.ToAbsolute(current).ToFloor();
|
||||||
Location blockCenter = block.ToCenter();
|
Location blockCenter = block.ToCenter();
|
||||||
bool res = handler.PlaceBlock(block, Direction.Down).Result;
|
bool res = handler.PlaceBlockAsync(block, Direction.Down).Result;
|
||||||
return r.SetAndReturn(string.Format(Translations.cmd_useblock_use, blockCenter.X, blockCenter.Y, blockCenter.Z, res ? "succeeded" : "failed"), res);
|
return r.SetAndReturn(string.Format(Translations.cmd_useblock_use, blockCenter.X, blockCenter.Y, blockCenter.Z, res ? "succeeded" : "failed"), res);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
38
MinecraftClient/EntityHandler/Effect.cs
Normal file
38
MinecraftClient/EntityHandler/Effect.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MinecraftClient.EntityHandler
|
||||||
|
{
|
||||||
|
public record Effect
|
||||||
|
{
|
||||||
|
public EffectType Type { init; get; }
|
||||||
|
|
||||||
|
public int EffectLevel { init; get; }
|
||||||
|
|
||||||
|
public ulong StartTick { init; get; }
|
||||||
|
|
||||||
|
public int DurationInTick { init; get; }
|
||||||
|
|
||||||
|
public bool IsFromBeacon { init; get; }
|
||||||
|
|
||||||
|
public bool ShowParticles { init; get; }
|
||||||
|
|
||||||
|
public bool ShowIcon { init; get; }
|
||||||
|
|
||||||
|
public Dictionary<string, object>? FactorData { init; get; } = null;
|
||||||
|
|
||||||
|
/* Factor Data
|
||||||
|
Name Type
|
||||||
|
padding_duration TAG_INT
|
||||||
|
factor_start TAG_FLOAT
|
||||||
|
factor_target TAG_FLOAT
|
||||||
|
factor_current TAG_FLOAT
|
||||||
|
effect_changed_timestamp TAG_INT
|
||||||
|
factor_previous_frame TAG_FLOAT
|
||||||
|
had_effect_last_tick TAG_BOOLEAN
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,9 @@
|
||||||
namespace MinecraftClient.Inventory
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a Minecraft effects
|
/// Represents a Minecraft effects
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum Effects
|
public enum EffectType
|
||||||
{
|
{
|
||||||
Speed = 1,
|
Speed = 1,
|
||||||
Slowness = 2,
|
Slowness = 2,
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
|
using MinecraftClient.Mapping;
|
||||||
using MinecraftClient.Protocol.Message;
|
using MinecraftClient.Protocol.Message;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an entity evolving into a Minecraft world
|
/// Represents an entity evolving into a Minecraft world
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
public enum EntityPose
|
public enum EntityPose
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents Minecraft Entity Types
|
/// Represents Minecraft Entity Types
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
public static class EntityTypeExtensions
|
public static class EntityTypeExtensions
|
||||||
{
|
{
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.EntityHandler
|
||||||
{
|
{
|
||||||
public enum InteractType
|
public enum InteractType
|
||||||
{
|
{
|
||||||
|
|
@ -39,8 +39,8 @@ namespace MinecraftClient.Inventory
|
||||||
if (ValidateSlots(source, dest, destContainer) &&
|
if (ValidateSlots(source, dest, destContainer) &&
|
||||||
HasItem(source) &&
|
HasItem(source) &&
|
||||||
((destContainer != null && !HasItem(dest, destContainer)) || (destContainer == null && !HasItem(dest))))
|
((destContainer != null && !HasItem(dest, destContainer)) || (destContainer == null && !HasItem(dest))))
|
||||||
return mc.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Result
|
return mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Result
|
||||||
&& mc.DoWindowAction(destContainer == null ? c.ID : destContainer.ID, dest, WindowActionType.LeftClick).Result;
|
&& mc.DoWindowActionAsync(destContainer == null ? c.ID : destContainer.ID, dest, WindowActionType.LeftClick).Result;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -57,9 +57,9 @@ namespace MinecraftClient.Inventory
|
||||||
if (ValidateSlots(slot1, slot2, destContainer) &&
|
if (ValidateSlots(slot1, slot2, destContainer) &&
|
||||||
HasItem(slot1) &&
|
HasItem(slot1) &&
|
||||||
(destContainer != null && HasItem(slot2, destContainer) || (destContainer == null && HasItem(slot2))))
|
(destContainer != null && HasItem(slot2, destContainer) || (destContainer == null && HasItem(slot2))))
|
||||||
return mc.DoWindowAction(c.ID, slot1, WindowActionType.LeftClick).Result
|
return mc.DoWindowActionAsync(c.ID, slot1, WindowActionType.LeftClick).Result
|
||||||
&& mc.DoWindowAction(destContainer == null ? c.ID : destContainer.ID, slot2, WindowActionType.LeftClick).Result
|
&& mc.DoWindowActionAsync(destContainer == null ? c.ID : destContainer.ID, slot2, WindowActionType.LeftClick).Result
|
||||||
&& mc.DoWindowAction(c.ID, slot1, WindowActionType.LeftClick).Result;
|
&& mc.DoWindowActionAsync(c.ID, slot1, WindowActionType.LeftClick).Result;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -104,14 +104,14 @@ namespace MinecraftClient.Inventory
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mc.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Wait(); // grab item
|
mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Wait(); // grab item
|
||||||
mc.DoWindowAction(c.ID, -999, startDragging).Wait();
|
mc.DoWindowActionAsync(c.ID, -999, startDragging).Wait();
|
||||||
foreach (var slot in availableSlots)
|
foreach (var slot in availableSlots)
|
||||||
{
|
{
|
||||||
mc.DoWindowAction(c.ID, slot, addDragging).Wait();
|
mc.DoWindowActionAsync(c.ID, slot, addDragging).Wait();
|
||||||
}
|
}
|
||||||
mc.DoWindowAction(c.ID, -999, endDragging).Wait();
|
mc.DoWindowActionAsync(c.ID, -999, endDragging).Wait();
|
||||||
mc.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Wait(); // put down item left (if any)
|
mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Wait(); // put down item left (if any)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else return false;
|
else return false;
|
||||||
|
|
|
||||||
|
|
@ -78,17 +78,17 @@
|
||||||
|
|
||||||
protected virtual void Log(object msg)
|
protected virtual void Log(object msg)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted(msg.ToString() ?? string.Empty);
|
ConsoleIO.WriteLineFormatted(msg.ToString() ?? string.Empty, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Log(string msg)
|
protected virtual void Log(string msg)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted(msg);
|
ConsoleIO.WriteLineFormatted(msg, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected virtual void Log(string msg, params object[] args)
|
protected virtual void Log(string msg, params object[] args)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLineFormatted(string.Format(msg, args));
|
ConsoleIO.WriteLineFormatted(string.Format(msg, args), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping.EntityPalettes
|
namespace MinecraftClient.Mapping.EntityPalettes
|
||||||
{
|
{
|
||||||
|
|
|
||||||
31
MinecraftClient/Mapping/MapData.cs
Normal file
31
MinecraftClient/Mapping/MapData.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Mapping
|
||||||
|
{
|
||||||
|
public record MapData
|
||||||
|
{
|
||||||
|
public int MapId { init; get; }
|
||||||
|
|
||||||
|
public byte Scale { init; get; }
|
||||||
|
|
||||||
|
public bool TrackingPosition { init; get; }
|
||||||
|
|
||||||
|
public bool Locked { init; get; }
|
||||||
|
|
||||||
|
public List<MapIcon> Icons { init; get; } = new();
|
||||||
|
|
||||||
|
public byte ColumnsUpdated { init; get; }
|
||||||
|
|
||||||
|
public byte RowsUpdated { init; get; }
|
||||||
|
|
||||||
|
public byte MapCoulmnX { init; get; }
|
||||||
|
|
||||||
|
public byte MapRowZ { init; get; }
|
||||||
|
|
||||||
|
public byte[]? Colors { init; get; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -140,17 +140,10 @@ namespace MinecraftClient.Mapping
|
||||||
/// <param name="timeout">How long to wait before stopping computation</param>
|
/// <param name="timeout">How long to wait before stopping computation</param>
|
||||||
/// <remarks>When location is unreachable, computation will reach timeout, then optionally fallback to a close location within maxOffset</remarks>
|
/// <remarks>When location is unreachable, computation will reach timeout, then optionally fallback to a close location within maxOffset</remarks>
|
||||||
/// <returns>A list of locations, or null if calculation failed</returns>
|
/// <returns>A list of locations, or null if calculation failed</returns>
|
||||||
public static Queue<Location>? CalculatePath(World world, Location start, Location goal, bool allowUnsafe, int maxOffset, int minOffset, TimeSpan timeout)
|
public static async Task<Queue<Location>?> CalculatePath(World world, Location start, Location goal, bool allowUnsafe, int maxOffset, int minOffset, TimeSpan timeout)
|
||||||
{
|
{
|
||||||
CancellationTokenSource cts = new();
|
CancellationTokenSource cts = new(timeout);
|
||||||
Task<Queue<Location>?> pathfindingTask = Task.Factory.StartNew(() => Movement.CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token));
|
return await Task.Run(() => { return CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token); }, cts.Token);
|
||||||
pathfindingTask.Wait(timeout);
|
|
||||||
if (!pathfindingTask.IsCompleted)
|
|
||||||
{
|
|
||||||
cts.Cancel();
|
|
||||||
pathfindingTask.Wait();
|
|
||||||
}
|
|
||||||
return pathfindingTask.Result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
|
|
||||||
namespace MinecraftClient.Mapping
|
namespace MinecraftClient.Mapping
|
||||||
{
|
{
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -56,7 +56,6 @@ namespace MinecraftClient
|
||||||
private static bool useMcVersionOnce = false;
|
private static bool useMcVersionOnce = false;
|
||||||
private static string settingsIniPath = "MinecraftClient.ini";
|
private static string settingsIniPath = "MinecraftClient.ini";
|
||||||
|
|
||||||
private static int CurrentThreadId;
|
|
||||||
private static bool RestartKeepSettings = false;
|
private static bool RestartKeepSettings = false;
|
||||||
private static int RestartAfter = -1, Exitcode = 0;
|
private static int RestartAfter = -1, Exitcode = 0;
|
||||||
|
|
||||||
|
|
@ -93,6 +92,8 @@ namespace MinecraftClient
|
||||||
if (BuildInfo != null)
|
if (BuildInfo != null)
|
||||||
ConsoleIO.WriteLineFormatted("§8" + BuildInfo);
|
ConsoleIO.WriteLineFormatted("§8" + BuildInfo);
|
||||||
|
|
||||||
|
ConsoleIO.WriteLine("\u001b[33m\u001b[46m▀\u001b[0m");
|
||||||
|
|
||||||
string? specifiedSettingFile = null;
|
string? specifiedSettingFile = null;
|
||||||
if (args.Length >= 1 && File.Exists(args[0]) && Settings.ToLowerIfNeed(Path.GetExtension(args[0])) == ".ini")
|
if (args.Length >= 1 && File.Exists(args[0]) && Settings.ToLowerIfNeed(Path.GetExtension(args[0])) == ".ini")
|
||||||
{
|
{
|
||||||
|
|
@ -194,8 +195,6 @@ namespace MinecraftClient
|
||||||
|
|
||||||
startupargs = args;
|
startupargs = args;
|
||||||
|
|
||||||
CurrentThreadId = Environment.CurrentManagedThreadId;
|
|
||||||
|
|
||||||
// Check for updates
|
// Check for updates
|
||||||
AsyncTaskHandler.CheckUpdate = Task.Run(async () =>
|
AsyncTaskHandler.CheckUpdate = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
|
|
@ -419,7 +418,6 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
else if (!loadSucceed)
|
else if (!loadSucceed)
|
||||||
{
|
{
|
||||||
ConsoleInteractive.ConsoleReader.StopReadThread();
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLine(string.Empty);
|
ConsoleIO.WriteLine(string.Empty);
|
||||||
|
|
@ -724,6 +722,7 @@ namespace MinecraftClient
|
||||||
var getServerInfoTask = GetServerInfoAsync(loginHttpClient, loginTask);
|
var getServerInfoTask = GetServerInfoAsync(loginHttpClient, loginTask);
|
||||||
var refreshPlayerKeyTask = RefreshPlayerKeyPair(loginHttpClient, loginTask);
|
var refreshPlayerKeyTask = RefreshPlayerKeyPair(loginHttpClient, loginTask);
|
||||||
|
|
||||||
|
// Todo: Detailed status display of login steps.
|
||||||
(result, session, playerKeyPair) = await loginTask;
|
(result, session, playerKeyPair) = await loginTask;
|
||||||
if (result == ProtocolHandler.LoginResult.Success && session != null)
|
if (result == ProtocolHandler.LoginResult.Success && session != null)
|
||||||
{
|
{
|
||||||
|
|
@ -808,11 +807,6 @@ namespace MinecraftClient
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int GetMainThreadId()
|
|
||||||
{
|
|
||||||
return CurrentThreadId;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reloads settings
|
/// Reloads settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -988,7 +982,7 @@ namespace MinecraftClient
|
||||||
public static Type[] GetTypesInNamespace(string nameSpace, Assembly? assembly = null)
|
public static Type[] GetTypesInNamespace(string nameSpace, Assembly? assembly = null)
|
||||||
{
|
{
|
||||||
if (assembly == null) { assembly = Assembly.GetExecutingAssembly(); }
|
if (assembly == null) { assembly = Assembly.GetExecutingAssembly(); }
|
||||||
return assembly.GetTypes().Where(t => String.Equals(t.Namespace, nameSpace, StringComparison.Ordinal)).ToArray();
|
return assembly.GetTypes().Where(t => string.Equals(t.Namespace, nameSpace, StringComparison.Ordinal)).ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -998,7 +992,7 @@ namespace MinecraftClient
|
||||||
{
|
{
|
||||||
if (typeof(Program)
|
if (typeof(Program)
|
||||||
.Assembly
|
.Assembly
|
||||||
.GetCustomAttributes(typeof(System.Reflection.AssemblyConfigurationAttribute), false)
|
.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)
|
||||||
.FirstOrDefault() is AssemblyConfigurationAttribute attribute)
|
.FirstOrDefault() is AssemblyConfigurationAttribute attribute)
|
||||||
BuildInfo = attribute.Configuration;
|
BuildInfo = attribute.Configuration;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ using System.IO;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Inventory.ItemPalettes;
|
using MinecraftClient.Inventory.ItemPalettes;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
|
|
|
||||||
|
|
@ -125,7 +125,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 0x02: await ReadData(1); await ReadNextString(); await ReadNextString(); await ReadData(4); break;
|
case 0x02: await ReadData(1); await ReadNextString(); await ReadNextString(); await ReadData(4); break;
|
||||||
case 0x03:
|
case 0x03:
|
||||||
string message = await ReadNextString();
|
string message = await ReadNextString();
|
||||||
handler.OnTextReceived(new ChatMessage(message, protocolversion >= 72, 0, Guid.Empty)); break;
|
await handler.OnTextReceivedAsync(new ChatMessage(message, protocolversion >= 72, 0, Guid.Empty)); break;
|
||||||
case 0x04: await ReadData(16); break;
|
case 0x04: await ReadData(16); break;
|
||||||
case 0x05: await ReadData(6); await ReadNextItemSlot(); break;
|
case 0x05: await ReadData(6); await ReadNextItemSlot(); break;
|
||||||
case 0x06: await ReadData(12); break;
|
case 0x06: await ReadData(12); break;
|
||||||
|
|
@ -196,7 +196,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 0xC9:
|
case 0xC9:
|
||||||
string name = await ReadNextString(); bool online = await ReadNextByte() != 0x00; await ReadData(2);
|
string name = await ReadNextString(); bool online = await ReadNextByte() != 0x00; await ReadData(2);
|
||||||
Guid FakeUUID = new(MD5.HashData(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
Guid FakeUUID = new(MD5.HashData(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||||
if (online) { handler.OnPlayerJoin(new PlayerInfo(name, FakeUUID)); } else { handler.OnPlayerLeave(FakeUUID); }
|
if (online) { await handler.OnPlayerJoinAsync(new PlayerInfo(name, FakeUUID)); } else { await handler.OnPlayerLeaveAsync(FakeUUID); }
|
||||||
break;
|
break;
|
||||||
case 0xCA: if (protocolversion >= 72) { await ReadData(9); } else await ReadData(3); break;
|
case 0xCA: if (protocolversion >= 72) { await ReadData(9); } else await ReadData(3); break;
|
||||||
case 0xCB:
|
case 0xCB:
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MinecraftClient.Commands;
|
using MinecraftClient.Commands;
|
||||||
using MinecraftClient.Crypto;
|
using MinecraftClient.Crypto;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Inventory.ItemPalettes;
|
using MinecraftClient.Inventory.ItemPalettes;
|
||||||
using MinecraftClient.Logger;
|
using MinecraftClient.Logger;
|
||||||
|
|
@ -71,6 +72,8 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
internal const int MC_1_19_Version = 759;
|
internal const int MC_1_19_Version = 759;
|
||||||
internal const int MC_1_19_2_Version = 760;
|
internal const int MC_1_19_2_Version = 760;
|
||||||
|
|
||||||
|
private ulong CurrentTick = 0;
|
||||||
|
|
||||||
private int autocomplete_transaction_id = 0;
|
private int autocomplete_transaction_id = 0;
|
||||||
private readonly Dictionary<int, short> window_actions = new();
|
private readonly Dictionary<int, short> window_actions = new();
|
||||||
private bool login_phase = true;
|
private bool login_phase = true;
|
||||||
|
|
@ -218,6 +221,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
while (await periodicTimer.WaitForNextTickAsync(CancelToken) && !CancelToken.IsCancellationRequested)
|
while (await periodicTimer.WaitForNextTickAsync(CancelToken) && !CancelToken.IsCancellationRequested)
|
||||||
{
|
{
|
||||||
|
++CurrentTick;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await handler.OnUpdate();
|
await handler.OnUpdate();
|
||||||
|
|
@ -226,7 +230,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
if (Config.Logging.DebugMessages)
|
if (Config.Logging.DebugMessages)
|
||||||
{
|
{
|
||||||
ConsoleIO.WriteLine($"{e.GetType().Name} when ticking: {e.Message}");
|
ConsoleIO.WriteLine($"{e.GetType().Name} on tick: {e.Message}");
|
||||||
if (e.StackTrace != null)
|
if (e.StackTrace != null)
|
||||||
ConsoleIO.WriteLine(e.StackTrace);
|
ConsoleIO.WriteLine(e.StackTrace);
|
||||||
}
|
}
|
||||||
|
|
@ -314,7 +318,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
await SendPacket(PacketTypesOut.Pong, packetData);
|
await SendPacket(PacketTypesOut.Pong, packetData);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.JoinGame:
|
case PacketTypesIn.JoinGame:
|
||||||
Task OnGameJoinedTask = handler.OnGameJoined();
|
Task OnGameJoinedTask = handler.OnGameJoinedAsync();
|
||||||
|
|
||||||
int playerEntityID = await dataTypes.ReadNextIntAsync(packetData);
|
int playerEntityID = await dataTypes.ReadNextIntAsync(packetData);
|
||||||
handler.OnReceivePlayerEntityID(playerEntityID);
|
handler.OnReceivePlayerEntityID(playerEntityID);
|
||||||
|
|
@ -439,7 +443,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else
|
else
|
||||||
senderUUID = Guid.Empty;
|
senderUUID = Guid.Empty;
|
||||||
|
|
||||||
handler.OnTextReceived(new(message, true, messageType, senderUUID));
|
await handler.OnTextReceivedAsync(new(message, true, messageType, senderUUID));
|
||||||
}
|
}
|
||||||
else if (protocolVersion == MC_1_19_Version) // 1.19
|
else if (protocolVersion == MC_1_19_Version) // 1.19
|
||||||
{
|
{
|
||||||
|
|
@ -477,7 +481,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatMessage chat = new(signedChat, true, messageType, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, messageSignature, verifyResult);
|
ChatMessage chat = new(signedChat, true, messageType, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, messageSignature, verifyResult);
|
||||||
handler.OnTextReceived(chat);
|
await handler.OnTextReceivedAsync(chat);
|
||||||
}
|
}
|
||||||
else // 1.19.1 +
|
else // 1.19.1 +
|
||||||
{
|
{
|
||||||
|
|
@ -554,7 +558,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
ChatMessage chat = new(signedChat, false, chatTypeId, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, headerSignature, verifyResult);
|
ChatMessage chat = new(signedChat, false, chatTypeId, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, headerSignature, verifyResult);
|
||||||
if (isOnlineMode && !chat.LacksSender())
|
if (isOnlineMode && !chat.LacksSender())
|
||||||
await Acknowledge(chat);
|
await Acknowledge(chat);
|
||||||
handler.OnTextReceived(chat);
|
await handler.OnTextReceivedAsync(chat);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.CombatEvent:
|
case PacketTypesIn.CombatEvent:
|
||||||
|
|
@ -567,7 +571,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
await dataTypes.SkipNextVarIntAsync(packetData);
|
await dataTypes.SkipNextVarIntAsync(packetData);
|
||||||
|
|
||||||
handler.OnPlayerKilled(
|
await handler.OnPlayerKilledAsync(
|
||||||
await dataTypes.ReadNextIntAsync(packetData),
|
await dataTypes.ReadNextIntAsync(packetData),
|
||||||
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
||||||
);
|
);
|
||||||
|
|
@ -578,7 +582,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case PacketTypesIn.DeathCombatEvent:
|
case PacketTypesIn.DeathCombatEvent:
|
||||||
await dataTypes.SkipNextVarIntAsync(packetData);
|
await dataTypes.SkipNextVarIntAsync(packetData);
|
||||||
|
|
||||||
handler.OnPlayerKilled(
|
await handler.OnPlayerKilledAsync(
|
||||||
await dataTypes.ReadNextIntAsync(packetData),
|
await dataTypes.ReadNextIntAsync(packetData),
|
||||||
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
||||||
);
|
);
|
||||||
|
|
@ -673,7 +677,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
await dataTypes.SkipNextLocationAsync(packetData); // Death location
|
await dataTypes.SkipNextLocationAsync(packetData); // Death location
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.OnRespawn();
|
await handler.OnRespawnAsync();
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.PlayerPositionAndLook:
|
case PacketTypesIn.PlayerPositionAndLook:
|
||||||
{
|
{
|
||||||
|
|
@ -907,7 +911,21 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
colors = await dataTypes.ReadNextByteArrayAsync(packetData);
|
colors = await dataTypes.ReadNextByteArrayAsync(packetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnMapData(mapid, scale, trackingPosition, locked, icons, columnsUpdated, rowsUpdated, mapCoulmnX, mapRowZ, colors);
|
MapData mapData = new()
|
||||||
|
{
|
||||||
|
MapId = mapid,
|
||||||
|
Scale = scale,
|
||||||
|
TrackingPosition = trackingPosition,
|
||||||
|
Locked = locked,
|
||||||
|
Icons = icons,
|
||||||
|
ColumnsUpdated = columnsUpdated,
|
||||||
|
RowsUpdated = rowsUpdated,
|
||||||
|
MapCoulmnX = mapCoulmnX,
|
||||||
|
MapRowZ = mapRowZ,
|
||||||
|
Colors = colors,
|
||||||
|
};
|
||||||
|
|
||||||
|
await handler.OnMapData(mapData);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.TradeList:
|
case PacketTypesIn.TradeList:
|
||||||
if (protocolVersion >= MC_1_14_Version && handler.GetInventoryEnabled())
|
if (protocolVersion >= MC_1_14_Version && handler.GetInventoryEnabled())
|
||||||
|
|
@ -985,7 +1003,20 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
fadeout = await dataTypes.ReadNextIntAsync(packetData);
|
fadeout = await dataTypes.ReadNextIntAsync(packetData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
handler.OnTitle(action2, titletext, subtitletext, actionbartext, fadein, stay, fadeout, json);
|
|
||||||
|
TitlePacket title = new()
|
||||||
|
{
|
||||||
|
Action = action2,
|
||||||
|
TitleText = titletext,
|
||||||
|
SubtitleText = subtitletext,
|
||||||
|
ActionbarText = actionbartext,
|
||||||
|
Stay = stay,
|
||||||
|
FadeIn = fadein,
|
||||||
|
FadeOut = fadeout,
|
||||||
|
JsonText = json,
|
||||||
|
};
|
||||||
|
|
||||||
|
await handler.OnTitle(title);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.MultiBlockChange:
|
case PacketTypesIn.MultiBlockChange:
|
||||||
|
|
@ -1253,14 +1284,14 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnPlayerJoin(new PlayerInfo(uuid, name, properties, gameMode, ping, displayName, keyExpiration, publicKey, signature));
|
await handler.OnPlayerJoinAsync(new PlayerInfo(uuid, name, properties, gameMode, ping, displayName, keyExpiration, publicKey, signature));
|
||||||
break;
|
break;
|
||||||
case 0x01: //Update gamemode
|
case 0x01: //Update gamemode
|
||||||
await handler.OnGamemodeUpdate(uuid, await dataTypes.ReadNextVarIntAsync(packetData));
|
await handler.OnGamemodeUpdate(uuid, await dataTypes.ReadNextVarIntAsync(packetData));
|
||||||
break;
|
break;
|
||||||
case 0x02: //Update latency
|
case 0x02: //Update latency
|
||||||
int latency = await dataTypes.ReadNextVarIntAsync(packetData);
|
int latency = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
handler.OnLatencyUpdate(uuid, latency); //Update latency;
|
await handler.OnLatencyUpdate(uuid, latency); //Update latency;
|
||||||
break;
|
break;
|
||||||
case 0x03: //Update display name
|
case 0x03: //Update display name
|
||||||
if (await dataTypes.ReadNextBoolAsync(packetData))
|
if (await dataTypes.ReadNextBoolAsync(packetData))
|
||||||
|
|
@ -1273,7 +1304,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 0x04: //Player Leave
|
case 0x04: //Player Leave
|
||||||
handler.OnPlayerLeave(uuid);
|
await handler.OnPlayerLeaveAsync(uuid);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
//Unknown player list item type
|
//Unknown player list item type
|
||||||
|
|
@ -1288,8 +1319,9 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
short ping = await dataTypes.ReadNextShortAsync(packetData);
|
short ping = await dataTypes.ReadNextShortAsync(packetData);
|
||||||
Guid FakeUUID = new(MD5.HashData(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
Guid FakeUUID = new(MD5.HashData(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||||
if (online)
|
if (online)
|
||||||
handler.OnPlayerJoin(new PlayerInfo(name, FakeUUID));
|
await handler.OnPlayerJoinAsync(new PlayerInfo(name, FakeUUID));
|
||||||
else handler.OnPlayerLeave(FakeUUID);
|
else
|
||||||
|
await handler.OnPlayerLeaveAsync(FakeUUID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.TabComplete:
|
case PacketTypesIn.TabComplete:
|
||||||
|
|
@ -1344,7 +1376,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
string title = await dataTypes.ReadNextStringAsync(packetData);
|
string title = await dataTypes.ReadNextStringAsync(packetData);
|
||||||
byte slots = await dataTypes.ReadNextByteAsync(packetData);
|
byte slots = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
Container inventory = new(windowID, inventoryType, ChatParser.ParseText(title));
|
Container inventory = new(windowID, inventoryType, ChatParser.ParseText(title));
|
||||||
handler.OnInventoryOpen(windowID, inventory);
|
await handler.OnInventoryOpenAsync(windowID, inventory);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -1353,7 +1385,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
int windowType = await dataTypes.ReadNextVarIntAsync(packetData);
|
int windowType = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
string title = await dataTypes.ReadNextStringAsync(packetData);
|
string title = await dataTypes.ReadNextStringAsync(packetData);
|
||||||
Container inventory = new(windowID, windowType, ChatParser.ParseText(title));
|
Container inventory = new(windowID, windowType, ChatParser.ParseText(title));
|
||||||
handler.OnInventoryOpen(windowID, inventory);
|
await handler.OnInventoryOpenAsync(windowID, inventory);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1362,7 +1394,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
byte windowID = await dataTypes.ReadNextByteAsync(packetData);
|
byte windowID = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
lock (window_actions) { window_actions[windowID] = 0; }
|
lock (window_actions) { window_actions[windowID] = 0; }
|
||||||
handler.OnInventoryClose(windowID);
|
await handler.OnInventoryCloseAsync(windowID);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.WindowItems:
|
case PacketTypesIn.WindowItems:
|
||||||
|
|
@ -1395,7 +1427,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (protocolVersion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above
|
if (protocolVersion >= MC_1_17_1_Version) // Carried Item - 1.17.1 and above
|
||||||
await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||||
|
|
||||||
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
await handler.OnWindowItemsAsync(windowId, inventorySlots, stateId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.WindowProperty:
|
case PacketTypesIn.WindowProperty:
|
||||||
|
|
@ -1403,7 +1435,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
short propertyId = await dataTypes.ReadNextShortAsync(packetData);
|
short propertyId = await dataTypes.ReadNextShortAsync(packetData);
|
||||||
short propertyValue = await dataTypes.ReadNextShortAsync(packetData);
|
short propertyValue = await dataTypes.ReadNextShortAsync(packetData);
|
||||||
|
|
||||||
handler.OnWindowProperties(containerId, propertyId, propertyValue);
|
await handler.OnWindowPropertiesAsync(containerId, propertyId, propertyValue);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.SetSlot:
|
case PacketTypesIn.SetSlot:
|
||||||
if (handler.GetInventoryEnabled())
|
if (handler.GetInventoryEnabled())
|
||||||
|
|
@ -1414,7 +1446,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
stateId = await dataTypes.ReadNextVarIntAsync(packetData); // State ID - 1.17.1 and above
|
stateId = await dataTypes.ReadNextVarIntAsync(packetData); // State ID - 1.17.1 and above
|
||||||
short slotID = await dataTypes.ReadNextShortAsync(packetData);
|
short slotID = await dataTypes.ReadNextShortAsync(packetData);
|
||||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||||
handler.OnSetSlot(windowID, slotID, item, stateId);
|
await handler.OnSetSlotAsync(windowID, slotID, item, stateId);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.WindowConfirmation:
|
case PacketTypesIn.WindowConfirmation:
|
||||||
|
|
@ -1452,7 +1484,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
Entity entity = await dataTypes.ReadNextEntity(packetData, entityPalette, false);
|
Entity entity = await dataTypes.ReadNextEntity(packetData, entityPalette, false);
|
||||||
handler.OnSpawnEntity(entity);
|
await handler.OnSpawnEntity(entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityEquipment:
|
case PacketTypesIn.EntityEquipment:
|
||||||
|
|
@ -1469,14 +1501,14 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
hasNext = bitsData >> 7 == 1;
|
hasNext = bitsData >> 7 == 1;
|
||||||
int slot2 = bitsData >> 1;
|
int slot2 = bitsData >> 1;
|
||||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||||
handler.OnEntityEquipment(entityid, slot2, item);
|
await handler.OnEntityEquipment(entityid, slot2, item);
|
||||||
} while (hasNext);
|
} while (hasNext);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int slot2 = await dataTypes.ReadNextVarIntAsync(packetData);
|
int slot2 = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||||
handler.OnEntityEquipment(entityid, slot2, item);
|
await handler.OnEntityEquipment(entityid, slot2, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1487,7 +1519,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
// packet before 1.15 has metadata at the end
|
// packet before 1.15 has metadata at the end
|
||||||
// this is not handled in dataTypes.ReadNextEntity()
|
// this is not handled in dataTypes.ReadNextEntity()
|
||||||
// we are simply ignoring leftover data in packet
|
// we are simply ignoring leftover data in packet
|
||||||
handler.OnSpawnEntity(entity);
|
await handler.OnSpawnEntity(entity);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.SpawnPlayer:
|
case PacketTypesIn.SpawnPlayer:
|
||||||
|
|
@ -1503,17 +1535,17 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
|
|
||||||
Location EntityLocation = new(X, Y, Z);
|
Location EntityLocation = new(X, Y, Z);
|
||||||
|
|
||||||
handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch);
|
await handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityEffect:
|
case PacketTypesIn.EntityEffect:
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
{
|
{
|
||||||
int entityid = await dataTypes.ReadNextVarIntAsync(packetData);
|
int entityid = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
Effects effect = Effects.Speed;
|
EffectType effectType = EffectType.Speed;
|
||||||
int effectId = protocolVersion >= MC_1_18_2_Version ?
|
int effectId = protocolVersion >= MC_1_18_2_Version ?
|
||||||
await dataTypes.ReadNextVarIntAsync(packetData) : await dataTypes.ReadNextByteAsync(packetData);
|
await dataTypes.ReadNextVarIntAsync(packetData) : await dataTypes.ReadNextByteAsync(packetData);
|
||||||
if (Enum.TryParse(effectId.ToString(), out effect))
|
if (Enum.TryParse(effectId.ToString(), out effectType))
|
||||||
{
|
{
|
||||||
int amplifier = await dataTypes.ReadNextByteAsync(packetData);
|
int amplifier = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
int duration = await dataTypes.ReadNextVarIntAsync(packetData);
|
int duration = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
|
|
@ -1529,7 +1561,19 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
factorCodec = await dataTypes.ReadNextNbtAsync(packetData);
|
factorCodec = await dataTypes.ReadNextNbtAsync(packetData);
|
||||||
}
|
}
|
||||||
|
|
||||||
handler.OnEntityEffect(entityid, effect, amplifier, duration, flags, hasFactorData, factorCodec);
|
Effect effect = new()
|
||||||
|
{
|
||||||
|
Type = effectType,
|
||||||
|
EffectLevel = amplifier,
|
||||||
|
StartTick = CurrentTick,
|
||||||
|
DurationInTick = duration,
|
||||||
|
IsFromBeacon = (flags & 0x01) > 0,
|
||||||
|
ShowParticles = (flags & 0x02) > 0,
|
||||||
|
ShowIcon = (flags & 0x04) > 0,
|
||||||
|
FactorData = factorCodec,
|
||||||
|
};
|
||||||
|
|
||||||
|
await handler.OnEntityEffect(entityid, effect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
@ -1544,7 +1588,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
entityList[i] = await dataTypes.ReadNextVarIntAsync(packetData);
|
entityList[i] = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
}
|
}
|
||||||
handler.OnDestroyEntities(entityList);
|
await handler.OnDestroyEntities(entityList);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityPosition:
|
case PacketTypesIn.EntityPosition:
|
||||||
|
|
@ -1558,7 +1602,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
DeltaX /= 128 * 32;
|
DeltaX /= 128 * 32;
|
||||||
DeltaY /= 128 * 32;
|
DeltaY /= 128 * 32;
|
||||||
DeltaZ /= 128 * 32;
|
DeltaZ /= 128 * 32;
|
||||||
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
await handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityPositionAndRotation:
|
case PacketTypesIn.EntityPositionAndRotation:
|
||||||
|
|
@ -1574,7 +1618,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
DeltaX /= 128 * 32;
|
DeltaX /= 128 * 32;
|
||||||
DeltaY /= 128 * 32;
|
DeltaY /= 128 * 32;
|
||||||
DeltaZ /= 128 * 32;
|
DeltaZ /= 128 * 32;
|
||||||
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
await handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityProperties:
|
case PacketTypesIn.EntityProperties:
|
||||||
|
|
@ -1609,7 +1653,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x);
|
if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x);
|
||||||
keys.Add(_key, _value);
|
keys.Add(_key, _value);
|
||||||
}
|
}
|
||||||
handler.OnEntityProperties(EntityID, keys);
|
await handler.OnEntityProperties(EntityID, keys);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityMetadata:
|
case PacketTypesIn.EntityMetadata:
|
||||||
|
|
@ -1641,20 +1685,20 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
int entityId = await dataTypes.ReadNextIntAsync(packetData);
|
int entityId = await dataTypes.ReadNextIntAsync(packetData);
|
||||||
byte status = await dataTypes.ReadNextByteAsync(packetData);
|
byte status = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
handler.OnEntityStatus(entityId, status);
|
await handler.OnEntityStatus(entityId, status);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.TimeUpdate:
|
case PacketTypesIn.TimeUpdate:
|
||||||
long WorldAge = await dataTypes.ReadNextLongAsync(packetData);
|
long WorldAge = await dataTypes.ReadNextLongAsync(packetData);
|
||||||
long TimeOfday = await dataTypes.ReadNextLongAsync(packetData);
|
long TimeOfday = await dataTypes.ReadNextLongAsync(packetData);
|
||||||
handler.OnTimeUpdate(WorldAge, TimeOfday);
|
await handler.OnTimeUpdate(WorldAge, TimeOfday);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.SystemChat:
|
case PacketTypesIn.SystemChat:
|
||||||
string systemMessage = await dataTypes.ReadNextStringAsync(packetData);
|
string systemMessage = await dataTypes.ReadNextStringAsync(packetData);
|
||||||
int msgType = await dataTypes.ReadNextVarIntAsync(packetData);
|
int msgType = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
if (msgType == 1 && !Config.Main.Advanced.ShowSystemMessages)
|
if (msgType == 1 && !Config.Main.Advanced.ShowSystemMessages)
|
||||||
break;
|
break;
|
||||||
handler.OnTextReceived(new(systemMessage, true, msgType, Guid.Empty, true));
|
await handler.OnTextReceivedAsync(new(systemMessage, true, msgType, Guid.Empty, true));
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.EntityTeleport:
|
case PacketTypesIn.EntityTeleport:
|
||||||
if (handler.GetEntityHandlingEnabled())
|
if (handler.GetEntityHandlingEnabled())
|
||||||
|
|
@ -1666,7 +1710,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
byte EntityYaw = await dataTypes.ReadNextByteAsync(packetData);
|
byte EntityYaw = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
byte EntityPitch = await dataTypes.ReadNextByteAsync(packetData);
|
byte EntityPitch = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
bool OnGround = await dataTypes.ReadNextBoolAsync(packetData);
|
bool OnGround = await dataTypes.ReadNextBoolAsync(packetData);
|
||||||
handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround);
|
await handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.UpdateHealth:
|
case PacketTypesIn.UpdateHealth:
|
||||||
|
|
@ -1677,13 +1721,13 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
else
|
else
|
||||||
food = await dataTypes.ReadNextShortAsync(packetData);
|
food = await dataTypes.ReadNextShortAsync(packetData);
|
||||||
await dataTypes.SkipNextFloatAsync(packetData); // Food Saturation
|
await dataTypes.SkipNextFloatAsync(packetData); // Food Saturation
|
||||||
handler.OnUpdateHealth(health, food);
|
await handler.OnUpdateHealth(health, food);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.SetExperience:
|
case PacketTypesIn.SetExperience:
|
||||||
float experiencebar = await dataTypes.ReadNextFloatAsync(packetData);
|
float experiencebar = await dataTypes.ReadNextFloatAsync(packetData);
|
||||||
int level = await dataTypes.ReadNextVarIntAsync(packetData);
|
int level = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
int totalexperience = await dataTypes.ReadNextVarIntAsync(packetData);
|
int totalexperience = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||||
handler.OnSetExperience(experiencebar, level, totalexperience);
|
await handler.OnSetExperience(experiencebar, level, totalexperience);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.Explosion:
|
case PacketTypesIn.Explosion:
|
||||||
Location explosionLocation = new(await dataTypes.ReadNextFloatAsync(packetData), await dataTypes.ReadNextFloatAsync(packetData), await dataTypes.ReadNextFloatAsync(packetData));
|
Location explosionLocation = new(await dataTypes.ReadNextFloatAsync(packetData), await dataTypes.ReadNextFloatAsync(packetData), await dataTypes.ReadNextFloatAsync(packetData));
|
||||||
|
|
@ -1700,11 +1744,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
float playerVelocityY = await dataTypes.ReadNextFloatAsync(packetData);
|
float playerVelocityY = await dataTypes.ReadNextFloatAsync(packetData);
|
||||||
float playerVelocityZ = await dataTypes.ReadNextFloatAsync(packetData);
|
float playerVelocityZ = await dataTypes.ReadNextFloatAsync(packetData);
|
||||||
|
|
||||||
handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
await handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.HeldItemChange:
|
case PacketTypesIn.HeldItemChange:
|
||||||
byte slot = await dataTypes.ReadNextByteAsync(packetData);
|
byte slot = await dataTypes.ReadNextByteAsync(packetData);
|
||||||
handler.OnHeldItemChange(slot);
|
await handler.OnHeldItemChange(slot);
|
||||||
break;
|
break;
|
||||||
case PacketTypesIn.ScoreboardObjective:
|
case PacketTypesIn.ScoreboardObjective:
|
||||||
string objectivename = await dataTypes.ReadNextStringAsync(packetData);
|
string objectivename = await dataTypes.ReadNextStringAsync(packetData);
|
||||||
|
|
@ -1771,6 +1815,15 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public ulong GetCurrentTick()
|
||||||
|
{
|
||||||
|
return CurrentTick;
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Disconnect from the server, cancel network reading.
|
/// Disconnect from the server, cancel network reading.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -1805,8 +1858,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
{
|
{
|
||||||
if (handler.GetNetworkPacketCaptureEnabled())
|
if (handler.GetNetworkPacketCaptureEnabled())
|
||||||
{
|
{
|
||||||
List<byte> clone = packetData.ToList();
|
await handler.OnNetworkPacketAsync(packetID, packetData.ToArray(), login_phase, false);
|
||||||
handler.OnNetworkPacket(packetID, clone, login_phase, false);
|
|
||||||
}
|
}
|
||||||
// log.Info("[C -> S] Sending packet " + packetID + " > " + dataTypes.ByteArrayToString(packetData.ToArray()));
|
// log.Info("[C -> S] Sending packet " + packetID + " > " + dataTypes.ByteArrayToString(packetData.ToArray()));
|
||||||
|
|
||||||
|
|
@ -2248,7 +2300,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="acknowledgment">Message acknowledgment</param>
|
/// <param name="acknowledgment">Message acknowledgment</param>
|
||||||
/// <returns>True if properly sent</returns>
|
/// <returns>True if properly sent</returns>
|
||||||
public async Task<bool> SendMessageAcknowledgment(LastSeenMessageList.Acknowledgment acknowledgment)
|
public async Task<bool> SendMessageAckAsync(LastSeenMessageList.Acknowledgment acknowledgment)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -2279,7 +2331,7 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
lastReceivedMessage = null;
|
lastReceivedMessage = null;
|
||||||
|
|
||||||
if (pendingAcknowledgments++ > 64)
|
if (pendingAcknowledgments++ > 64)
|
||||||
await SendMessageAcknowledgment(ConsumeAcknowledgment());
|
await SendMessageAckAsync(ConsumeAcknowledgment());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Logger;
|
using MinecraftClient.Logger;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
|
|
@ -53,18 +54,18 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="packetData">A copy of Packet Data</param>
|
/// <param name="packetData">A copy of Packet Data</param>
|
||||||
/// <param name="isLogin">The packet is login phase or playing phase</param>
|
/// <param name="isLogin">The packet is login phase or playing phase</param>
|
||||||
/// <param name="isInbound">The packet is received from server or sent by client</param>
|
/// <param name="isInbound">The packet is received from server or sent by client</param>
|
||||||
void OnNetworkPacket(int packetID, List<byte> packetData, bool isLogin, bool isInbound);
|
Task OnNetworkPacketAsync(int packetID, byte[] packetData, bool isLogin, bool isInbound);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a server was successfully joined
|
/// Called when a server was successfully joined
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task OnGameJoined();
|
Task OnGameJoinedAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Received chat/system message from the server
|
/// Received chat/system message from the server
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="message">Message received</param>
|
/// <param name="message">Message received</param>
|
||||||
public void OnTextReceived(ChatMessage message);
|
Task OnTextReceivedAsync(ChatMessage message);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Will be called every animations of the hit and place block
|
/// Will be called every animations of the hit and place block
|
||||||
|
|
@ -90,7 +91,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the protocol handler receives a title
|
/// This method is called when the protocol handler receives a title
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnTitle(int action, string titletext, string subtitletext, string actionbartext, int fadein, int stay, int fadeout, string json);
|
Task OnTitle(TitlePacket title);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when receiving a connection keep-alive from the server
|
/// Called when receiving a connection keep-alive from the server
|
||||||
|
|
@ -116,36 +117,36 @@ namespace MinecraftClient.Protocol
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an inventory is opened
|
/// Called when an inventory is opened
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnInventoryOpen(int inventoryID, Container inventory);
|
Task OnInventoryOpenAsync(int inventoryID, Container inventory);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an inventory is closed
|
/// Called when an inventory is closed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnInventoryClose(int inventoryID);
|
Task OnInventoryCloseAsync(int inventoryID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the player respawns, which happens on login, respawn and world change.
|
/// Called when the player respawns, which happens on login, respawn and world change.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
void OnRespawn();
|
Task OnRespawnAsync();
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Triggered when a new player joins the game
|
/// Triggered when a new player joins the game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="player">player info</param>
|
/// <param name="player">player info</param>
|
||||||
public void OnPlayerJoin(PlayerInfo player);
|
Task OnPlayerJoinAsync(PlayerInfo player);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a player has left the game
|
/// This method is called when a player has left the game
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">UUID of the player</param>
|
/// <param name="uuid">UUID of the player</param>
|
||||||
void OnPlayerLeave(Guid uuid);
|
Task OnPlayerLeaveAsync(Guid uuid);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when a player has been killed by another entity
|
/// This method is called when a player has been killed by another entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="killerEntityId">Killer's entity if</param>
|
/// <param name="killerEntityId">Killer's entity if</param>
|
||||||
/// <param name="chatMessage">message sent in chat when player is killed</param>
|
/// <param name="chatMessage">message sent in chat when player is killed</param>
|
||||||
void OnPlayerKilled(int killerEntityId, string chatMessage);
|
Task OnPlayerKilledAsync(int killerEntityId, string chatMessage);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the server sets the new location for the player
|
/// Called when the server sets the new location for the player
|
||||||
|
|
@ -161,7 +162,7 @@ namespace MinecraftClient.Protocol
|
||||||
void OnConnectionLost(ChatBot.DisconnectReason reason, string message);
|
void OnConnectionLost(ChatBot.DisconnectReason reason, string message);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called ~10 times per second (10 ticks per second)
|
/// Called ~20 times per second (20 ticks per second)
|
||||||
/// Useful for updating bots in other parts of the program
|
/// Useful for updating bots in other parts of the program
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task OnUpdate();
|
Task OnUpdate();
|
||||||
|
|
@ -171,14 +172,14 @@ namespace MinecraftClient.Protocol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="channel">The channel to register.</param>
|
/// <param name="channel">The channel to register.</param>
|
||||||
/// <param name="bot">The bot to register the channel for.</param>
|
/// <param name="bot">The bot to register the channel for.</param>
|
||||||
Task RegisterPluginChannel(string channel, ChatBot bot);
|
Task RegisterPluginChannelAsync(string channel, ChatBot bot);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Unregisters the given plugin channel for the given bot.
|
/// Unregisters the given plugin channel for the given bot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="channel">The channel to unregister.</param>
|
/// <param name="channel">The channel to unregister.</param>
|
||||||
/// <param name="bot">The bot to unregister the channel for.</param>
|
/// <param name="bot">The bot to unregister the channel for.</param>
|
||||||
Task UnregisterPluginChannel(string channel, ChatBot bot);
|
Task UnregisterPluginChannelAsync(string channel, ChatBot bot);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sends a plugin channel packet to the server.
|
/// Sends a plugin channel packet to the server.
|
||||||
|
|
@ -188,7 +189,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="data">The payload for the packet.</param>
|
/// <param name="data">The payload for the packet.</param>
|
||||||
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
/// <param name="sendEvenIfNotRegistered">Whether the packet should be sent even if the server or the client hasn't registered it yet.</param>
|
||||||
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
/// <returns>Whether the packet was sent: true if it was sent, false if there was a connection error or it wasn't registered.</returns>
|
||||||
Task<bool> SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
Task<bool> SendPluginChannelMessageAsync(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a plugin channel message was sent from the server.
|
/// Called when a plugin channel message was sent from the server.
|
||||||
|
|
@ -201,7 +202,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// Called when an entity has spawned
|
/// Called when an entity has spawned
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entity">Spawned entity</param>
|
/// <param name="entity">Spawned entity</param>
|
||||||
void OnSpawnEntity(Entity entity);
|
Task OnSpawnEntity(Entity entity);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an entity has spawned
|
/// Called when an entity has spawned
|
||||||
|
|
@ -209,7 +210,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="entityid">Entity id</param>
|
/// <param name="entityid">Entity id</param>
|
||||||
/// <param name="slot">Equipment slot. 0: main hand, 1: off hand, 2–5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)/param>
|
/// <param name="slot">Equipment slot. 0: main hand, 1: off hand, 2–5: armor slot (2: boots, 3: leggings, 4: chestplate, 5: helmet)/param>
|
||||||
/// <param name="item">Item/param>
|
/// <param name="item">Item/param>
|
||||||
void OnEntityEquipment(int entityid, int slot, Item? item);
|
Task OnEntityEquipment(int entityid, int slot, Item? item);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a player spawns or enters the client's render distance
|
/// Called when a player spawns or enters the client's render distance
|
||||||
|
|
@ -219,13 +220,13 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="location">Entity location</param>
|
/// <param name="location">Entity location</param>
|
||||||
/// <param name="yaw">Player head yaw</param>
|
/// <param name="yaw">Player head yaw</param>
|
||||||
/// <param name="pitch">Player head pitch</param>
|
/// <param name="pitch">Player head pitch</param>
|
||||||
void OnSpawnPlayer(int entityID, Guid uuid, Location location, byte yaw, byte pitch);
|
Task OnSpawnPlayer(int entityID, Guid uuid, Location location, byte yaw, byte pitch);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when entities have despawned
|
/// Called when entities have despawned
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="EntityID">List of Entity ID that have despawned</param>
|
/// <param name="EntityID">List of Entity ID that have despawned</param>
|
||||||
void OnDestroyEntities(int[] EntityID);
|
Task OnDestroyEntities(int[] EntityID);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an entity moved by coordinate offset
|
/// Called when an entity moved by coordinate offset
|
||||||
|
|
@ -235,7 +236,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="Dy">Y offset</param>
|
/// <param name="Dy">Y offset</param>
|
||||||
/// <param name="Dz">Z offset</param>
|
/// <param name="Dz">Z offset</param>
|
||||||
/// <param name="onGround">TRUE if on ground</param>
|
/// <param name="onGround">TRUE if on ground</param>
|
||||||
void OnEntityPosition(int entityID, Double dx, Double dy, Double dz, bool onGround);
|
Task OnEntityPosition(int entityID, Double dx, Double dy, Double dz, bool onGround);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an entity moved to fixed coordinates
|
/// Called when an entity moved to fixed coordinates
|
||||||
|
|
@ -245,28 +246,28 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="Dy">Y</param>
|
/// <param name="Dy">Y</param>
|
||||||
/// <param name="Dz">Z</param>
|
/// <param name="Dz">Z</param>
|
||||||
/// <param name="onGround">TRUE if on ground</param>
|
/// <param name="onGround">TRUE if on ground</param>
|
||||||
void OnEntityTeleport(int entityID, Double x, Double y, Double z, bool onGround);
|
Task OnEntityTeleport(int entityID, Double x, Double y, Double z, bool onGround);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when additional properties have been received for an entity
|
/// Called when additional properties have been received for an entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="EntityID">Entity ID</param>
|
/// <param name="EntityID">Entity ID</param>
|
||||||
/// <param name="prop">Dictionary of properties</param>
|
/// <param name="prop">Dictionary of properties</param>
|
||||||
void OnEntityProperties(int entityID, Dictionary<string, Double> prop);
|
Task OnEntityProperties(int entityID, Dictionary<string, Double> prop);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the status of an entity have been changed
|
/// Called when the status of an entity have been changed
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="entityID">Entity ID</param>
|
/// <param name="entityID">Entity ID</param>
|
||||||
/// <param name="status">Status ID</param>
|
/// <param name="status">Status ID</param>
|
||||||
void OnEntityStatus(int entityID, byte status);
|
Task OnEntityStatus(int entityID, byte status);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the world age has been updated
|
/// Called when the world age has been updated
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="WorldAge">World age</param>
|
/// <param name="WorldAge">World age</param>
|
||||||
/// <param name="TimeOfDay">Time of Day</param>
|
/// <param name="TimeOfDay">Time of Day</param>
|
||||||
void OnTimeUpdate(long worldAge, long timeOfDay);
|
Task OnTimeUpdate(long worldAge, long timeOfDay);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// When received window properties from server.
|
/// When received window properties from server.
|
||||||
|
|
@ -275,7 +276,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="inventoryID">Inventory ID</param>
|
/// <param name="inventoryID">Inventory ID</param>
|
||||||
/// <param name="propertyId">Property ID</param>
|
/// <param name="propertyId">Property ID</param>
|
||||||
/// <param name="propertyValue">Property Value</param>
|
/// <param name="propertyValue">Property Value</param>
|
||||||
public void OnWindowProperties(byte inventoryID, short propertyId, short propertyValue);
|
Task OnWindowPropertiesAsync(byte inventoryID, short propertyId, short propertyValue);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when inventory items have been received
|
/// Called when inventory items have been received
|
||||||
|
|
@ -283,7 +284,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="inventoryID">Inventory ID</param>
|
/// <param name="inventoryID">Inventory ID</param>
|
||||||
/// <param name="itemList">Item list</param>
|
/// <param name="itemList">Item list</param>
|
||||||
/// <param name="stateId">State ID</param>
|
/// <param name="stateId">State ID</param>
|
||||||
void OnWindowItems(byte inventoryID, Dictionary<int, Item> itemList, int stateId);
|
Task OnWindowItemsAsync(byte inventoryID, Dictionary<int, Item> itemList, int stateId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a single slot has been updated inside an inventory
|
/// Called when a single slot has been updated inside an inventory
|
||||||
|
|
@ -292,14 +293,14 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="slotID">Slot ID</param>
|
/// <param name="slotID">Slot ID</param>
|
||||||
/// <param name="item">Item (may be null for empty slot)</param>
|
/// <param name="item">Item (may be null for empty slot)</param>
|
||||||
/// <param name="stateId">State ID</param>
|
/// <param name="stateId">State ID</param>
|
||||||
void OnSetSlot(byte inventoryID, short slotID, Item? item, int stateId);
|
Task OnSetSlotAsync(byte inventoryID, short slotID, Item? item, int stateId);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when player health or hunger changed.
|
/// Called when player health or hunger changed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="health"></param>
|
/// <param name="health"></param>
|
||||||
/// <param name="food"></param>
|
/// <param name="food"></param>
|
||||||
void OnUpdateHealth(float health, int food);
|
Task OnUpdateHealth(float health, int food);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the health of an entity changed
|
/// Called when the health of an entity changed
|
||||||
|
|
@ -321,7 +322,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="location">Explosion location</param>
|
/// <param name="location">Explosion location</param>
|
||||||
/// <param name="strength">Explosion strength</param>
|
/// <param name="strength">Explosion strength</param>
|
||||||
/// <param name="affectedBlocks">Amount of affected blocks</param>
|
/// <param name="affectedBlocks">Amount of affected blocks</param>
|
||||||
void OnExplosion(Location location, float strength, int affectedBlocks);
|
Task OnExplosion(Location location, float strength, int affectedBlocks);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a player's game mode has changed
|
/// Called when a player's game mode has changed
|
||||||
|
|
@ -335,7 +336,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="uuid">Affected player's UUID</param>
|
/// <param name="uuid">Affected player's UUID</param>
|
||||||
/// <param name="latency">latency</param>
|
/// <param name="latency">latency</param>
|
||||||
void OnLatencyUpdate(Guid uuid, int latency);
|
Task OnLatencyUpdate(Guid uuid, int latency);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when Experience bar is updated
|
/// Called when Experience bar is updated
|
||||||
|
|
@ -343,14 +344,14 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="Experiencebar">Experience bar level</param>
|
/// <param name="Experiencebar">Experience bar level</param>
|
||||||
/// <param name="Level">Player Level</param>
|
/// <param name="Level">Player Level</param>
|
||||||
/// <param name="TotalExperience">Total experience</param>
|
/// <param name="TotalExperience">Total experience</param>
|
||||||
void OnSetExperience(float Experiencebar, int Level, int TotalExperience);
|
Task OnSetExperience(float Experiencebar, int Level, int TotalExperience);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when client need to change slot.
|
/// Called when client need to change slot.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Used for setting player slot after joining game</remarks>
|
/// <remarks>Used for setting player slot after joining game</remarks>
|
||||||
/// <param name="slot"></param>
|
/// <param name="slot"></param>
|
||||||
void OnHeldItemChange(byte slot);
|
Task OnHeldItemChange(byte slot);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an update of the map is sent by the server, take a look at https://wiki.vg/Protocol#Map_Data for more info on the fields
|
/// Called when an update of the map is sent by the server, take a look at https://wiki.vg/Protocol#Map_Data for more info on the fields
|
||||||
|
|
@ -366,7 +367,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="mapCoulmnX">x offset of the westernmost column</param>
|
/// <param name="mapCoulmnX">x offset of the westernmost column</param>
|
||||||
/// <param name="mapRowZ">z offset of the northernmost row</param>
|
/// <param name="mapRowZ">z offset of the northernmost row</param>
|
||||||
/// <param name="colors">a byte array of colors on the map</param>
|
/// <param name="colors">a byte array of colors on the map</param>
|
||||||
void OnMapData(int mapid, byte scale, bool trackingPosition, bool locked, List<MapIcon> icons, byte columnsUpdated, byte rowsUpdated, byte mapCoulmnX, byte mapRowZ, byte[]? colors);
|
Task OnMapData(MapData mapData);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the Player entity ID has been received from the server
|
/// Called when the Player entity ID has been received from the server
|
||||||
|
|
@ -384,7 +385,7 @@ namespace MinecraftClient.Protocol
|
||||||
/// <param name="flags">effect flags</param>
|
/// <param name="flags">effect flags</param>
|
||||||
/// <param name="hasFactorData">has factor data</param>
|
/// <param name="hasFactorData">has factor data</param>
|
||||||
/// <param name="factorCodec">factorCodec</param>
|
/// <param name="factorCodec">factorCodec</param>
|
||||||
void OnEntityEffect(int entityid, Effects effect, int amplifier, int duration, byte flags, bool hasFactorData, Dictionary<String, object>? factorCodec);
|
Task OnEntityEffect(int entityid, Effect effect);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when coreboardObjective
|
/// Called when coreboardObjective
|
||||||
|
|
|
||||||
|
|
@ -15,6 +15,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
private const int BufferSize = 1024;
|
private const int BufferSize = 1024;
|
||||||
|
|
||||||
public Socket Client;
|
public Socket Client;
|
||||||
|
public bool HwAccelerateEnable { init; get; }
|
||||||
private bool inStreamEnded = false;
|
private bool inStreamEnded = false;
|
||||||
|
|
||||||
private readonly IAesHandler Aes;
|
private readonly IAesHandler Aes;
|
||||||
|
|
@ -44,11 +45,20 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
AesBufSend = new byte[BlockSize];
|
AesBufSend = new byte[BlockSize];
|
||||||
|
|
||||||
if (FasterAesX86.IsSupported())
|
if (FasterAesX86.IsSupported())
|
||||||
|
{
|
||||||
|
HwAccelerateEnable = true;
|
||||||
Aes = new FasterAesX86(key);
|
Aes = new FasterAesX86(key);
|
||||||
else if (FasterAesArm.IsSupported())
|
}
|
||||||
|
else if (false && FasterAesArm.IsSupported()) // Further testing required
|
||||||
|
{
|
||||||
|
HwAccelerateEnable = true;
|
||||||
Aes = new FasterAesArm(key);
|
Aes = new FasterAesArm(key);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
HwAccelerateEnable = false;
|
||||||
Aes = new BasicAes(key);
|
Aes = new BasicAes(key);
|
||||||
|
}
|
||||||
|
|
||||||
key.CopyTo(InputBuf.Slice(0, BlockSize));
|
key.CopyTo(InputBuf.Slice(0, BlockSize));
|
||||||
key.CopyTo(OutputBuf.Slice(0, BlockSize));
|
key.CopyTo(OutputBuf.Slice(0, BlockSize));
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
public int CompressionThreshold { get; set; } = 0;
|
public int CompressionThreshold { get; set; } = 0;
|
||||||
|
|
||||||
|
|
||||||
private SemaphoreSlim SendSemaphore = new SemaphoreSlim(1, 1);
|
private SemaphoreSlim SendSemaphore = new(1, 1);
|
||||||
|
|
||||||
private Task LastSendTask = Task.CompletedTask;
|
private Task LastSendTask = Task.CompletedTask;
|
||||||
|
|
||||||
|
|
@ -78,7 +78,8 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
/// <param name="buffer">data to send</param>
|
/// <param name="buffer">data to send</param>
|
||||||
public async Task SendAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
|
public async Task SendAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
await SendSemaphore.WaitAsync();
|
await SendSemaphore.WaitAsync(cancellationToken);
|
||||||
|
if (cancellationToken.IsCancellationRequested) return;
|
||||||
await LastSendTask;
|
await LastSendTask;
|
||||||
LastSendTask = WriteStream.WriteAsync(buffer, cancellationToken).AsTask();
|
LastSendTask = WriteStream.WriteAsync(buffer, cancellationToken).AsTask();
|
||||||
SendSemaphore.Release();
|
SendSemaphore.Release();
|
||||||
|
|
@ -86,7 +87,6 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
|
|
||||||
public async Task<Tuple<int, PacketStream>> GetNextPacket(bool handleCompress, CancellationToken cancellationToken = default)
|
public async Task<Tuple<int, PacketStream>> GetNextPacket(bool handleCompress, CancellationToken cancellationToken = default)
|
||||||
{
|
{
|
||||||
// ConsoleIO.WriteLine("GetNextPacket");
|
|
||||||
if (packetStream != null)
|
if (packetStream != null)
|
||||||
{
|
{
|
||||||
await packetStream.DisposeAsync();
|
await packetStream.DisposeAsync();
|
||||||
|
|
@ -105,9 +105,18 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
ZlibBaseStream zlibBaseStream = new(AesStream ?? ReadStream, packetSize: packetSize - readed);
|
ZlibBaseStream zlibBaseStream = new(AesStream ?? ReadStream, packetSize: packetSize - readed);
|
||||||
ZLibStream zlibStream = new(zlibBaseStream, CompressionMode.Decompress, leaveOpen: false);
|
ZLibStream zlibStream = new(zlibBaseStream, CompressionMode.Decompress, leaveOpen: false);
|
||||||
|
|
||||||
zlibBaseStream.BufferSize = 16;
|
if (AesStream == null || AesStream.HwAccelerateEnable)
|
||||||
(packetID, readed) = await ReceiveVarIntRaw(zlibStream, cancellationToken);
|
{
|
||||||
zlibBaseStream.BufferSize = 512;
|
zlibBaseStream.BufferSize = 64;
|
||||||
|
(packetID, readed) = await ReceiveVarIntRaw(zlibStream, cancellationToken);
|
||||||
|
zlibBaseStream.BufferSize = 1024;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
zlibBaseStream.BufferSize = 16;
|
||||||
|
(packetID, readed) = await ReceiveVarIntRaw(zlibStream, cancellationToken);
|
||||||
|
zlibBaseStream.BufferSize = 256;
|
||||||
|
}
|
||||||
|
|
||||||
// ConsoleIO.WriteLine("packetID = " + packetID + ", readed = " + zlibBaseStream.packetReaded + ", size = " + packetSize + " -> " + sizeUncompressed);
|
// ConsoleIO.WriteLine("packetID = " + packetID + ", readed = " + zlibBaseStream.packetReaded + ", size = " + packetSize + " -> " + sizeUncompressed);
|
||||||
|
|
||||||
|
|
@ -131,7 +140,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
||||||
byte[] b = new byte[1];
|
byte[] b = new byte[1];
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
await stream.ReadAsync(b);
|
await stream.ReadAsync(b, cancellationToken);
|
||||||
i |= (b[0] & 0x7F) << j++ * 7;
|
i |= (b[0] & 0x7F) << j++ * 7;
|
||||||
if (j > 5) throw new OverflowException("VarInt too big");
|
if (j > 5) throw new OverflowException("VarInt too big");
|
||||||
if ((b[0] & 0x80) != 128) break;
|
if ((b[0] & 0x80) != 128) break;
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ namespace MinecraftClient.Protocol
|
||||||
|
|
||||||
// Entity info
|
// Entity info
|
||||||
|
|
||||||
public Mapping.Entity? entity;
|
public EntityHandler.Entity? entity;
|
||||||
|
|
||||||
// For message signature
|
// For message signature
|
||||||
|
|
||||||
|
|
|
||||||
27
MinecraftClient/Protocol/TitlePacket.cs
Normal file
27
MinecraftClient/Protocol/TitlePacket.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Protocol
|
||||||
|
{
|
||||||
|
public record TitlePacket
|
||||||
|
{
|
||||||
|
public int Action { init; get; }
|
||||||
|
|
||||||
|
public string TitleText { init; get; } = string.Empty;
|
||||||
|
|
||||||
|
public string SubtitleText { init; get; } = string.Empty;
|
||||||
|
|
||||||
|
public string ActionbarText { init; get; } = string.Empty;
|
||||||
|
|
||||||
|
public int Stay { init; get; }
|
||||||
|
|
||||||
|
public int FadeIn { init; get; }
|
||||||
|
|
||||||
|
public int FadeOut { init; get; }
|
||||||
|
|
||||||
|
public string JsonText { init; get; } = string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -3643,6 +3643,15 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Player Inventory.
|
||||||
|
/// </summary>
|
||||||
|
internal static string cmd_inventory_player_inventory {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("cmd.inventory.player_inventory", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Right.
|
/// Looks up a localized string similar to Right.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -4130,6 +4139,24 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to File {0} does not exist..
|
||||||
|
/// </summary>
|
||||||
|
internal static string config_file_not_exist {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("config.file_not_exist", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to Invalid file extension {0} in {1}, requires {2}..
|
||||||
|
/// </summary>
|
||||||
|
internal static string config_invaild_file_extension {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("config.invaild_file_extension", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to [Settings] The language code is invalid!.
|
/// Looks up a localized string similar to [Settings] The language code is invalid!.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -4148,6 +4175,15 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to You are using an older color scheme and some colors may not be displayed correctly. It is recommended that you switch to a modern terminal for a better display experience..
|
||||||
|
/// </summary>
|
||||||
|
internal static string config_legacy_color {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("config.legacy_color", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Settings have been loaded from {0}.
|
/// Looks up a localized string similar to Settings have been loaded from {0}.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -5130,6 +5166,16 @@ namespace MinecraftClient {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Looks up a localized string similar to An exception occurred while processing event {0}:
|
||||||
|
///{1}.
|
||||||
|
/// </summary>
|
||||||
|
internal static string mcc_chatbot_event_exception {
|
||||||
|
get {
|
||||||
|
return ResourceManager.GetString("mcc.chatbot_event_exception", resourceCulture);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Looks up a localized string similar to Connecting to {0}....
|
/// Looks up a localized string similar to Connecting to {0}....
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
|
|
@ -2040,4 +2040,20 @@ Logging in...</value>
|
||||||
<data name="config.invaild_login_method" xml:space="preserve">
|
<data name="config.invaild_login_method" xml:space="preserve">
|
||||||
<value>[Settings] Only Microsoft accounts support logging in using the browser method.</value>
|
<value>[Settings] Only Microsoft accounts support logging in using the browser method.</value>
|
||||||
</data>
|
</data>
|
||||||
|
<data name="config.invaild_file_extension" xml:space="preserve">
|
||||||
|
<value>Invalid file extension {0} in {1}, requires {2}.</value>
|
||||||
|
</data>
|
||||||
|
<data name="config.file_not_exist" xml:space="preserve">
|
||||||
|
<value>File {0} does not exist.</value>
|
||||||
|
</data>
|
||||||
|
<data name="config.legacy_color" xml:space="preserve">
|
||||||
|
<value>You are using an older color scheme and some colors may not be displayed correctly. It is recommended that you switch to a modern terminal for a better display experience.</value>
|
||||||
|
</data>
|
||||||
|
<data name="cmd.inventory.player_inventory" xml:space="preserve">
|
||||||
|
<value>Player Inventory</value>
|
||||||
|
</data>
|
||||||
|
<data name="mcc.chatbot_event_exception" xml:space="preserve">
|
||||||
|
<value>An exception occurred while processing event {0}:
|
||||||
|
{1}</value>
|
||||||
|
</data>
|
||||||
</root>
|
</root>
|
||||||
|
|
@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Brigadier.NET;
|
using Brigadier.NET;
|
||||||
using MinecraftClient.CommandHandler;
|
using MinecraftClient.CommandHandler;
|
||||||
|
using MinecraftClient.EntityHandler;
|
||||||
using MinecraftClient.Inventory;
|
using MinecraftClient.Inventory;
|
||||||
using MinecraftClient.Mapping;
|
using MinecraftClient.Mapping;
|
||||||
using static MinecraftClient.Settings;
|
using static MinecraftClient.Settings;
|
||||||
|
|
@ -37,7 +38,7 @@ namespace MinecraftClient.Scripting
|
||||||
//Handler will be automatically set on bot loading, don't worry about this
|
//Handler will be automatically set on bot loading, don't worry about this
|
||||||
public void SetHandler(McClient handler) { _handler = handler; }
|
public void SetHandler(McClient handler) { _handler = handler; }
|
||||||
protected void SetMaster(ChatBot master) { this.master = master; }
|
protected void SetMaster(ChatBot master) { this.master = master; }
|
||||||
protected void LoadBot(ChatBot bot) { Handler.BotUnLoad(bot).Wait(); Handler.BotLoad(bot); }
|
protected void LoadBot(ChatBot bot) { Handler.BotUnLoad(bot).Wait(); Handler.BotLoad(bot).Wait(); }
|
||||||
protected ChatBot[] GetLoadedChatBots() { return Handler.GetLoadedChatBots(); }
|
protected ChatBot[] GetLoadedChatBots() { return Handler.GetLoadedChatBots(); }
|
||||||
protected void UnLoadBot(ChatBot bot) { Handler.BotUnLoad(bot).Wait(); }
|
protected void UnLoadBot(ChatBot bot) { Handler.BotUnLoad(bot).Wait(); }
|
||||||
private McClient? _handler = null;
|
private McClient? _handler = null;
|
||||||
|
|
@ -105,6 +106,12 @@ namespace MinecraftClient.Scripting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public virtual void Initialize() { }
|
public virtual void Initialize() { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public virtual Tuple<McClientEventType, Func<object?, Task>>[]? InitializeEventCallbacks() { return null; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This method is called when the bot is being unloaded, you can use it to free up resources like DB connections
|
/// This method is called when the bot is being unloaded, you can use it to free up resources like DB connections
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -260,14 +267,6 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="gamemode">New Game Mode (0: Survival, 1: Creative, 2: Adventure, 3: Spectator).</param>
|
/// <param name="gamemode">New Game Mode (0: Survival, 1: Creative, 2: Adventure, 3: Spectator).</param>
|
||||||
public virtual void OnGamemodeUpdate(string playername, Guid uuid, int gamemode) { }
|
public virtual void OnGamemodeUpdate(string playername, Guid uuid, int gamemode) { }
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Called when the Game Mode has been updated for a player
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="playername">Player Name</param>
|
|
||||||
/// <param name="uuid">Player UUID</param>
|
|
||||||
/// <param name="gamemode">New Game Mode (0: Survival, 1: Creative, 2: Adventure, 3: Spectator).</param>
|
|
||||||
public virtual async Task OnGamemodeUpdateAsync(string playername, Guid uuid, int gamemode) { await Task.CompletedTask; }
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when the Latency has been updated for a player
|
/// Called when the Latency has been updated for a player
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
@ -337,7 +336,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="amplifier">effect amplifier</param>
|
/// <param name="amplifier">effect amplifier</param>
|
||||||
/// <param name="duration">effect duration</param>
|
/// <param name="duration">effect duration</param>
|
||||||
/// <param name="flags">effect flags</param>
|
/// <param name="flags">effect flags</param>
|
||||||
public virtual void OnEntityEffect(Entity entity, Effects effect, int amplifier, int duration, byte flags) { }
|
public virtual void OnEntityEffect(Entity entity, EffectType effect, int amplifier, int duration, byte flags) { }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when a scoreboard objective updated
|
/// Called when a scoreboard objective updated
|
||||||
|
|
@ -518,7 +517,7 @@ namespace MinecraftClient.Scripting
|
||||||
protected bool SendText(string text, bool sendImmediately = false)
|
protected bool SendText(string text, bool sendImmediately = false)
|
||||||
{
|
{
|
||||||
LogToConsole("Sending '" + text + "'");
|
LogToConsole("Sending '" + text + "'");
|
||||||
Handler.SendText(text).Wait();
|
Handler.SendTextAsync(text).Wait();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -982,7 +981,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="localVars">Local variables for use in the Script</param>
|
/// <param name="localVars">Local variables for use in the Script</param>
|
||||||
protected void RunScript(string filename, string? playername = null, Dictionary<string, object>? localVars = null)
|
protected void RunScript(string filename, string? playername = null, Dictionary<string, object>? localVars = null)
|
||||||
{
|
{
|
||||||
Handler.BotLoad(new ChatBots.Script(filename, playername, localVars));
|
Handler.BotLoad(new ChatBots.Script(filename, playername, localVars)).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -991,7 +990,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="chatBot">ChatBot to load</param>
|
/// <param name="chatBot">ChatBot to load</param>
|
||||||
protected void BotLoad(ChatBot chatBot)
|
protected void BotLoad(ChatBot chatBot)
|
||||||
{
|
{
|
||||||
Handler.BotLoad(chatBot);
|
Handler.BotLoad(chatBot).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1037,7 +1036,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private bool SendEntityAction(Protocol.EntityActionType entityAction)
|
private bool SendEntityAction(Protocol.EntityActionType entityAction)
|
||||||
{
|
{
|
||||||
return Handler.SendEntityAction(entityAction).Result;
|
return Handler.SendEntityActionAsync(entityAction).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1045,7 +1044,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private async Task<bool> SendEntityActionAsync(Protocol.EntityActionType entityAction)
|
private async Task<bool> SendEntityActionAsync(Protocol.EntityActionType entityAction)
|
||||||
{
|
{
|
||||||
return await Handler.SendEntityAction(entityAction);
|
return await Handler.SendEntityActionAsync(entityAction);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1056,7 +1055,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
||||||
protected bool DigBlock(Location location, bool swingArms = true, bool lookAtBlock = true)
|
protected bool DigBlock(Location location, bool swingArms = true, bool lookAtBlock = true)
|
||||||
{
|
{
|
||||||
return Handler.DigBlock(location, swingArms, lookAtBlock).Result;
|
return Handler.DigBlockAsync(location, swingArms, lookAtBlock).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1064,7 +1063,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected bool SetSlot(int slotNum)
|
protected bool SetSlot(int slotNum)
|
||||||
{
|
{
|
||||||
return Handler.ChangeSlot((short)slotNum).Result;
|
return Handler.ChangeSlotAsync((short)slotNum).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1116,7 +1115,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>True if a path has been found</returns>
|
/// <returns>True if a path has been found</returns>
|
||||||
protected bool MoveToLocation(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
|
protected bool MoveToLocation(Location location, bool allowUnsafe = false, bool allowDirectTeleport = false, int maxOffset = 0, int minOffset = 0, TimeSpan? timeout = null)
|
||||||
{
|
{
|
||||||
return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout);
|
return Handler.MoveToAsync(location, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1297,7 +1296,7 @@ namespace MinecraftClient.Scripting
|
||||||
protected void RegisterPluginChannel(string channel)
|
protected void RegisterPluginChannel(string channel)
|
||||||
{
|
{
|
||||||
registeredPluginChannels.Add(channel);
|
registeredPluginChannels.Add(channel);
|
||||||
Handler.RegisterPluginChannel(channel, this).Wait();
|
Handler.RegisterPluginChannelAsync(channel, this).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1307,7 +1306,7 @@ namespace MinecraftClient.Scripting
|
||||||
protected void UnregisterPluginChannel(string channel)
|
protected void UnregisterPluginChannel(string channel)
|
||||||
{
|
{
|
||||||
registeredPluginChannels.RemoveAll(chan => chan == channel);
|
registeredPluginChannels.RemoveAll(chan => chan == channel);
|
||||||
Handler.UnregisterPluginChannel(channel, this).Wait();
|
Handler.UnregisterPluginChannelAsync(channel, this).Wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1327,7 +1326,7 @@ namespace MinecraftClient.Scripting
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Handler.SendPluginChannelMessage(channel, data, sendEvenIfNotRegistered).Result;
|
return Handler.SendPluginChannelMessageAsync(channel, data, sendEvenIfNotRegistered).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1349,7 +1348,7 @@ namespace MinecraftClient.Scripting
|
||||||
[Obsolete("Prefer using InteractType enum instead of int for interaction type")]
|
[Obsolete("Prefer using InteractType enum instead of int for interaction type")]
|
||||||
protected bool InteractEntity(int EntityID, int type, Hand hand = Hand.MainHand)
|
protected bool InteractEntity(int EntityID, int type, Hand hand = Hand.MainHand)
|
||||||
{
|
{
|
||||||
return Handler.InteractEntity(EntityID, (InteractType)type, hand).Result;
|
return Handler.InteractEntityAsync(EntityID, (InteractType)type, hand).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1361,7 +1360,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE in case of success</returns>
|
/// <returns>TRUE in case of success</returns>
|
||||||
protected bool InteractEntity(int EntityID, InteractType type, Hand hand = Hand.MainHand)
|
protected bool InteractEntity(int EntityID, InteractType type, Hand hand = Hand.MainHand)
|
||||||
{
|
{
|
||||||
return Handler.InteractEntity(EntityID, type, hand).Result;
|
return Handler.InteractEntityAsync(EntityID, type, hand).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1375,7 +1374,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE if item given successfully</returns>
|
/// <returns>TRUE if item given successfully</returns>
|
||||||
protected bool CreativeGive(int slot, ItemType itemType, int count, Dictionary<string, object>? nbt = null)
|
protected bool CreativeGive(int slot, ItemType itemType, int count, Dictionary<string, object>? nbt = null)
|
||||||
{
|
{
|
||||||
return Handler.DoCreativeGive(slot, itemType, count, nbt).Result;
|
return Handler.DoCreativeGiveAsync(slot, itemType, count, nbt).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1397,7 +1396,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE if animation successfully done</returns>
|
/// <returns>TRUE if animation successfully done</returns>
|
||||||
public bool SendAnimation(Hand hand = Hand.MainHand)
|
public bool SendAnimation(Hand hand = Hand.MainHand)
|
||||||
{
|
{
|
||||||
return Handler.DoAnimation((int)hand).Result;
|
return Handler.DoAnimationAsync((int)hand).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1406,7 +1405,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE if successful</returns>
|
/// <returns>TRUE if successful</returns>
|
||||||
protected bool UseItemInHand()
|
protected bool UseItemInHand()
|
||||||
{
|
{
|
||||||
return Handler.UseItemOnHand().Result;
|
return Handler.UseItemOnHandAsync().Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1415,7 +1414,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE if successful</returns>
|
/// <returns>TRUE if successful</returns>
|
||||||
protected bool UseItemInLeftHand()
|
protected bool UseItemInLeftHand()
|
||||||
{
|
{
|
||||||
return Handler.UseItemOnLeftHand().Result;
|
return Handler.UseItemOnOffHandAsync().Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1436,7 +1435,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE if successfully placed</returns>
|
/// <returns>TRUE if successfully placed</returns>
|
||||||
public bool SendPlaceBlock(Location location, Direction blockFace, Hand hand = Hand.MainHand)
|
public bool SendPlaceBlock(Location location, Direction blockFace, Hand hand = Hand.MainHand)
|
||||||
{
|
{
|
||||||
return Handler.PlaceBlock(location, blockFace, hand).Result;
|
return Handler.PlaceBlockAsync(location, blockFace, hand).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1467,7 +1466,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>TRUE in case of success</returns>
|
/// <returns>TRUE in case of success</returns>
|
||||||
protected bool WindowAction(int inventoryId, int slot, WindowActionType actionType)
|
protected bool WindowAction(int inventoryId, int slot, WindowActionType actionType)
|
||||||
{
|
{
|
||||||
return Handler.DoWindowAction(inventoryId, slot, actionType).Result;
|
return Handler.DoWindowActionAsync(inventoryId, slot, actionType).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1487,7 +1486,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>True if success</returns>
|
/// <returns>True if success</returns>
|
||||||
protected bool ChangeSlot(short slot)
|
protected bool ChangeSlot(short slot)
|
||||||
{
|
{
|
||||||
return Handler.ChangeSlot(slot).Result;
|
return Handler.ChangeSlotAsync(slot).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1518,7 +1517,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="line4"> text1 four</param>
|
/// <param name="line4"> text1 four</param>
|
||||||
protected bool UpdateSign(Location location, string line1, string line2, string line3, string line4)
|
protected bool UpdateSign(Location location, string line1, string line2, string line3, string line4)
|
||||||
{
|
{
|
||||||
return Handler.UpdateSign(location, line1, line2, line3, line4).Result;
|
return Handler.UpdateSignAsync(location, line1, line2, line3, line4).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1527,7 +1526,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="selectedSlot">Trade slot to select, starts at 0.</param>
|
/// <param name="selectedSlot">Trade slot to select, starts at 0.</param>
|
||||||
protected bool SelectTrade(int selectedSlot)
|
protected bool SelectTrade(int selectedSlot)
|
||||||
{
|
{
|
||||||
return Handler.SelectTrade(selectedSlot).Result;
|
return Handler.SelectTradeAsync(selectedSlot).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1536,7 +1535,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="entity">player to teleport to</param>
|
/// <param name="entity">player to teleport to</param>
|
||||||
protected bool SpectatorTeleport(Entity entity)
|
protected bool SpectatorTeleport(Entity entity)
|
||||||
{
|
{
|
||||||
return Handler.Spectate(entity).Result;
|
return Handler.SpectateAsync(entity).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1545,7 +1544,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="uuid">uuid of entity to teleport to</param>
|
/// <param name="uuid">uuid of entity to teleport to</param>
|
||||||
protected bool SpectatorTeleport(Guid UUID)
|
protected bool SpectatorTeleport(Guid UUID)
|
||||||
{
|
{
|
||||||
return Handler.SpectateByUUID(UUID).Result;
|
return Handler.SpectateByUuidAsync(UUID).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1557,7 +1556,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <param name="flags">command block flags</param>
|
/// <param name="flags">command block flags</param>
|
||||||
protected bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
|
protected bool UpdateCommandBlock(Location location, string command, CommandBlockMode mode, CommandBlockFlags flags)
|
||||||
{
|
{
|
||||||
return Handler.UpdateCommandBlock(location, command, mode, flags).Result;
|
return Handler.UpdateCommandBlockAsync(location, command, mode, flags).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1567,7 +1566,7 @@ namespace MinecraftClient.Scripting
|
||||||
/// <returns>True if success</returns>
|
/// <returns>True if success</returns>
|
||||||
protected bool CloseInventory(int inventoryID)
|
protected bool CloseInventory(int inventoryID)
|
||||||
{
|
{
|
||||||
return Handler.CloseInventory(inventoryID).Result;
|
return Handler.CloseInventoryAsync(inventoryID).Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
@ -1585,7 +1584,7 @@ namespace MinecraftClient.Scripting
|
||||||
protected bool Respawn()
|
protected bool Respawn()
|
||||||
{
|
{
|
||||||
if (Handler.GetHealth() <= 0)
|
if (Handler.GetHealth() <= 0)
|
||||||
return Handler.SendRespawnPacket().Result;
|
return Handler.SendRespawnPacketAsync().Result;
|
||||||
else return false;
|
else return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
68
MinecraftClient/Scripting/McClientEventType.cs
Normal file
68
MinecraftClient/Scripting/McClientEventType.cs
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace MinecraftClient.Scripting
|
||||||
|
{
|
||||||
|
public enum McClientEventType
|
||||||
|
{
|
||||||
|
/* Internal Events */
|
||||||
|
Initialize,
|
||||||
|
ClientDisconnect, /* Tuple<ChatBot.DisconnectReason, string>(reason, message) */
|
||||||
|
ClientTick,
|
||||||
|
InternalCommand,
|
||||||
|
NetworkPacket, /* Tuple<int, byte[], bool, bool>(packetID, packetData, isLogin, isInbound) */
|
||||||
|
ServerTpsUpdate, /* double(tps) */
|
||||||
|
|
||||||
|
/* General in-game events */
|
||||||
|
BlockBreakAnimation,
|
||||||
|
BlockChange,
|
||||||
|
Enchantments, /* EnchantmentData(lastEnchantment) */
|
||||||
|
Explosion, /* Tuple<Location, float, int>(location, strength, affectedBlocks) */
|
||||||
|
GameJoin,
|
||||||
|
MapDataReceive,
|
||||||
|
PluginMessage,
|
||||||
|
RainLevelChange,
|
||||||
|
ScoreboardUpdate,
|
||||||
|
ScoreUpdate,
|
||||||
|
TextReceive, /* Tuple<string, string>(messageText, message.content) */
|
||||||
|
ThunderLevelChange,
|
||||||
|
TimeUpdate, /* Tuple<long, long>(WorldAge, TimeOfDay) */
|
||||||
|
TitleReceive, /* TitlePacket(title) */
|
||||||
|
TradeListReceive,
|
||||||
|
|
||||||
|
/* Player Events */
|
||||||
|
PlayerLatencyUpdate, /* Tuple<PlayerInfo, int>(player, latency) */
|
||||||
|
PlayerJoin, /* PlayerInfo(player) */
|
||||||
|
PlayerKilled, /* Tuple<Entity, string>(killer, chatMessage) */
|
||||||
|
PlayerLeave, /* Tuple<Guid, PlayerInfo?>(uuid, playerInfo) */
|
||||||
|
PlayerPropertyReceive, /* Dictionary<string, double>(prop) */
|
||||||
|
PlayerStatusUpdate, /* byte(status) */
|
||||||
|
|
||||||
|
/* Player's own events */
|
||||||
|
Death, /* null */
|
||||||
|
ExperienceChange, /* Tuple<float, int, int>(Experiencebar, Level, TotalExperience) */
|
||||||
|
GamemodeUpdate, /* Tuple<PlayerInfo, int>(player, gamemode) */
|
||||||
|
HealthUpdate, /* Tuple<float, int>(health, food) */
|
||||||
|
HeldItemChange, /* byte(slot) */
|
||||||
|
Respawn,
|
||||||
|
|
||||||
|
/* Inventory-related events */
|
||||||
|
InventoryClose, /* int(inventoryID) */
|
||||||
|
InventoryOpen, /* int(inventoryID) */
|
||||||
|
InventoryProperties, /* Tuple<int, int, int>(inventoryID, propertyId, propertyValue) */
|
||||||
|
InventoryUpdate, /* int(inventoryID) */
|
||||||
|
|
||||||
|
/* Entity-related events */
|
||||||
|
EntityAnimation,
|
||||||
|
EntityDespawn, /* Entity(entity) */
|
||||||
|
EntityEffect, /* Tuple<Entity, Effect>(entity, effect) */
|
||||||
|
EntityEquipment, /* Tuple<Entity, int, Item?>(entity, slot, item) */
|
||||||
|
EntityHealth,
|
||||||
|
EntityMetadata,
|
||||||
|
EntityMove, /* Entity(entity) */
|
||||||
|
EntitySpawn, /* Entity(entity) */
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -129,7 +129,7 @@ namespace MinecraftClient
|
||||||
public ChatBotConfig ChatBot
|
public ChatBotConfig ChatBot
|
||||||
{
|
{
|
||||||
get { return ChatBotConfigHealper.Config; }
|
get { return ChatBotConfigHealper.Config; }
|
||||||
set { ChatBotConfigHealper.Config = value; }
|
set { ChatBotConfigHealper.Config = value; ChatBotConfigHealper.Config.OnSettingUpdate(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -797,6 +797,9 @@ namespace MinecraftClient
|
||||||
|
|
||||||
public void OnSettingUpdate()
|
public void OnSettingUpdate()
|
||||||
{
|
{
|
||||||
|
if (General.ConsoleColorMode == ConsoleColorModeType.legacy_4bit)
|
||||||
|
ConsoleIO.WriteLineFormatted("§8" + Translations.config_legacy_color, true);
|
||||||
|
|
||||||
// Reader
|
// Reader
|
||||||
ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Input;
|
ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Input;
|
||||||
|
|
||||||
|
|
@ -806,7 +809,7 @@ namespace MinecraftClient
|
||||||
ConsoleInteractive.ConsoleWriter.UseVT100ColorCode = General.ConsoleColorMode != ConsoleColorModeType.legacy_4bit;
|
ConsoleInteractive.ConsoleWriter.UseVT100ColorCode = General.ConsoleColorMode != ConsoleColorModeType.legacy_4bit;
|
||||||
|
|
||||||
// Buffer
|
// Buffer
|
||||||
General.History_Input_Records =
|
General.History_Input_Records =
|
||||||
ConsoleInteractive.ConsoleBuffer.SetBackreadBufferLimit(General.History_Input_Records);
|
ConsoleInteractive.ConsoleBuffer.SetBackreadBufferLimit(General.History_Input_Records);
|
||||||
|
|
||||||
// Suggestion
|
// Suggestion
|
||||||
|
|
@ -1252,6 +1255,8 @@ namespace MinecraftClient
|
||||||
[TomlDoNotInlineObject]
|
[TomlDoNotInlineObject]
|
||||||
public class ChatBotConfig
|
public class ChatBotConfig
|
||||||
{
|
{
|
||||||
|
public void OnSettingUpdate() { }
|
||||||
|
|
||||||
[TomlPrecedingComment("$ChatBot.Alerts$")]
|
[TomlPrecedingComment("$ChatBot.Alerts$")]
|
||||||
public ChatBots.Alerts.Configs Alerts
|
public ChatBots.Alerts.Configs Alerts
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue