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
|
||||
url = https://github.com/breadbyte/ConsoleInteractive
|
||||
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
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
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
|
||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleInteractive", "ConsoleInteractive\ConsoleInteractive\ConsoleInteractive\ConsoleInteractive.csproj", "{93DA4D71-EFAD-4493-BE21-A105AF663660}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MinecraftProtocolLibrary", "MinecraftProtocolLibrary\MinecraftProtocolLibrary\MinecraftProtocolLibrary.csproj", "{B6EA6A06-0EF8-4931-93EA-68EB02D69FE9}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
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}.Release|Any CPU.ActiveCfg = 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
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ExtensibilityGlobals) = postSolution
|
||||
RESX_ShowErrorsInErrorList = False
|
||||
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
|
||||
RESX_SortFileContentOnSave = False
|
||||
SolutionGuid = {6DED60F4-9CF4-4DB3-8966-582B2EBE8487}
|
||||
RESX_ShowErrorsInErrorList = False
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Scripting;
|
||||
using Tomlet.Attributes;
|
||||
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.CommandHandler.Patch;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Scripting;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ using Brigadier.NET;
|
|||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.CommandHandler.Patch;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Scripting;
|
||||
using Tomlet.Attributes;
|
||||
|
|
|
|||
|
|
@ -356,11 +356,12 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
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)
|
||||
{
|
||||
int RL = 0, GL = 0, BL = 0, RR = 0, GR = 0, BR = 0;
|
||||
double mid_dx = (double)(scale - 1) / 2;
|
||||
int RUL = 0, GUL = 0, BUL = 0, RUR = 0, GUR = 0, BUR = 0;
|
||||
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 dx = 0; dx < scale; ++dx)
|
||||
|
|
@ -368,40 +369,57 @@ namespace MinecraftClient.ChatBots
|
|||
int x = Math.Min(base_x + dx, map.Width - 1);
|
||||
int y = Math.Min(base_y + dy, map.Height - 1);
|
||||
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 (dx >= mid_dx)
|
||||
if (dy >= mid)
|
||||
{
|
||||
RR += color.R; GR += color.G; BR += color.B;
|
||||
RDL += color.R; GDL += color.G; BDL += color.B;
|
||||
}
|
||||
}
|
||||
if (dx >= mid)
|
||||
{
|
||||
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;
|
||||
RL = (int)Math.Round((double)RL / pixel_cnt);
|
||||
GL = (int)Math.Round((double)GL / pixel_cnt);
|
||||
BL = (int)Math.Round((double)BL / pixel_cnt);
|
||||
RR = (int)Math.Round((double)RR / pixel_cnt);
|
||||
GR = (int)Math.Round((double)GR / pixel_cnt);
|
||||
BR = (int)Math.Round((double)BR / pixel_cnt);
|
||||
int pixel_cnt = ((scale + 1) / 2) * ((scale + 1) / 2);
|
||||
RDL = (int)Math.Round((double)RDL / pixel_cnt);
|
||||
GDL = (int)Math.Round((double)GDL / pixel_cnt);
|
||||
BDL = (int)Math.Round((double)BDL / pixel_cnt);
|
||||
RDR = (int)Math.Round((double)RDR / pixel_cnt);
|
||||
GDR = (int)Math.Round((double)GDR / pixel_cnt);
|
||||
BDR = (int)Math.Round((double)BDR / pixel_cnt);
|
||||
|
||||
if (RL == last_R && GL == last_G && BL == last_B)
|
||||
sb.Append(' ');
|
||||
else
|
||||
{
|
||||
sb.Append(ColorHelper.GetColorEscapeCode((byte)RL, (byte)GL, (byte)BL, false)).Append(' ');
|
||||
last_R = RL; last_G = GL; last_B = BL;
|
||||
}
|
||||
RUL = (int)Math.Round((double)RUL / pixel_cnt);
|
||||
GUL = (int)Math.Round((double)GUL / pixel_cnt);
|
||||
BUL = (int)Math.Round((double)BUL / pixel_cnt);
|
||||
RUR = (int)Math.Round((double)RUR / pixel_cnt);
|
||||
GUR = (int)Math.Round((double)GUR / pixel_cnt);
|
||||
BUR = (int)Math.Round((double)BUR / pixel_cnt);
|
||||
|
||||
if (RR == last_R && GR == last_G && BR == last_B)
|
||||
sb.Append(' ');
|
||||
else
|
||||
{
|
||||
sb.Append(ColorHelper.GetColorEscapeCode((byte)RR, (byte)GR, (byte)BR, false)).Append(' ');
|
||||
last_R = RR; last_G = GR; last_B = BR;
|
||||
}
|
||||
string colorCode = ColorHelper.GetColorEscapeCode((byte)RUL, (byte)GUL, (byte)BUL, true);
|
||||
if (lastFg != colorCode) { sb.Append(colorCode); lastFg = colorCode; }
|
||||
colorCode = ColorHelper.GetColorEscapeCode((byte)RDL, (byte)GDL, (byte)BDL, false);
|
||||
if (lagtBg != colorCode) { sb.Append(colorCode); lagtBg = colorCode; }
|
||||
sb.Append('▀');
|
||||
|
||||
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)
|
||||
sb.Append(ColorHelper.GetResetEscapeCode());
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ namespace MinecraftClient.ChatBots
|
|||
//Load the given file from the startup parameters
|
||||
if (LookForScript(ref file!))
|
||||
{
|
||||
lines = System.IO.File.ReadAllLines(file, Encoding.UTF8);
|
||||
lines = File.ReadAllLines(file, Encoding.UTF8);
|
||||
csharp = file.EndsWith(".cs");
|
||||
thread = null;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
using MinecraftClient.Scripting;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using MinecraftClient.Scripting;
|
||||
|
||||
namespace MinecraftClient.ChatBots
|
||||
{
|
||||
|
|
@ -8,6 +10,19 @@ namespace MinecraftClient.ChatBots
|
|||
|
||||
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)
|
||||
{
|
||||
string message = "";
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ using Brigadier.NET.ArgumentTypes;
|
|||
using Brigadier.NET.Context;
|
||||
using Brigadier.NET.Exceptions;
|
||||
using Brigadier.NET.Suggestion;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.CommandHandler.ArgumentType
|
||||
{
|
||||
|
|
|
|||
|
|
@ -21,14 +21,20 @@ namespace MinecraftClient.CommandHandler.ArgumentType
|
|||
public override WindowActionType Parse(IStringReader reader)
|
||||
{
|
||||
reader.SkipWhitespace();
|
||||
string inputStr = reader.ReadString();
|
||||
foreach (var action in SupportActions)
|
||||
string inputStr = reader.ReadString().ToLower();
|
||||
return inputStr switch
|
||||
{
|
||||
string actionStr = action.ToString();
|
||||
if (string.Compare(inputStr, actionStr, true) == 0)
|
||||
return action;
|
||||
}
|
||||
throw CommandSyntaxException.BuiltInExceptions.LiteralIncorrect().CreateWithContext(reader, inputStr);
|
||||
"left" => WindowActionType.LeftClick,
|
||||
"leftclick" => WindowActionType.LeftClick,
|
||||
"right" => WindowActionType.RightClick,
|
||||
"rightclick" => WindowActionType.RightClick,
|
||||
"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)
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ using Brigadier.NET;
|
|||
using Brigadier.NET.ArgumentTypes;
|
||||
using Brigadier.NET.Context;
|
||||
using Brigadier.NET.Suggestion;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.CommandHandler.ArgumentType
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using Brigadier.NET.Context;
|
||||
using MinecraftClient.CommandHandler.ArgumentType;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.CommandHandler
|
||||
{
|
||||
|
|
@ -31,9 +32,9 @@ namespace MinecraftClient.CommandHandler
|
|||
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()
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ namespace MinecraftClient.Commands
|
|||
private static int DoAnimation(CmdResult r, bool mainhand)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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)
|
||||
|
|
@ -113,7 +113,7 @@ namespace MinecraftClient.Commands
|
|||
return r.SetAndReturn(Status.FailChunkNotLoad,
|
||||
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(() =>
|
||||
{
|
||||
|
|
@ -137,7 +137,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
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(
|
||||
Translations.cmd_bed_trying_to_use,
|
||||
|
|
@ -174,7 +174,7 @@ namespace MinecraftClient.Commands
|
|||
blockCenter.X,
|
||||
blockCenter.Y,
|
||||
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())
|
||||
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));
|
||||
else
|
||||
return r.SetAndReturn(Status.Fail, Translations.cmd_changeSlot_fail);
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ namespace MinecraftClient.Commands
|
|||
Block block = handler.GetWorld().GetBlock(blockToBreak);
|
||||
if (block.Type == Material.Air)
|
||||
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();
|
||||
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);
|
||||
else if (block.Type == Material.Air)
|
||||
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()));
|
||||
else
|
||||
return r.SetAndReturn(Status.Fail, Translations.cmd_dig_fail);
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace MinecraftClient.Commands
|
|||
var p = inventories[inventoryId];
|
||||
int[] targetItems = p.SearchItem(itemType);
|
||||
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));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ using System.Text;
|
|||
using Brigadier.NET;
|
||||
using Brigadier.NET.Builder;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
using static MinecraftClient.CommandHandler.CmdResult;
|
||||
|
|
@ -166,12 +167,12 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
if (action == ActionType.Attack)
|
||||
{
|
||||
handler.InteractEntity(entity2.Key, InteractType.Attack).Wait();
|
||||
handler.InteractEntityAsync(entity2.Key, InteractType.Attack).Wait();
|
||||
actionst = Translations.cmd_entityCmd_attacked;
|
||||
}
|
||||
else if (action == ActionType.Use)
|
||||
{
|
||||
handler.InteractEntity(entity2.Key, InteractType.Interact).Wait();
|
||||
handler.InteractEntityAsync(entity2.Key, InteractType.Interact).Wait();
|
||||
actionst = Translations.cmd_entityCmd_used;
|
||||
}
|
||||
actioncount++;
|
||||
|
|
@ -251,7 +252,7 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
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;
|
||||
if (string.IsNullOrEmpty(displayName))
|
||||
|
|
@ -311,10 +312,10 @@ namespace MinecraftClient.Commands
|
|||
switch (action)
|
||||
{
|
||||
case ActionType.Attack:
|
||||
handler.InteractEntity(entity.ID, InteractType.Attack).Wait();
|
||||
handler.InteractEntityAsync(entity.ID, InteractType.Attack).Wait();
|
||||
return Translations.cmd_entityCmd_attacked;
|
||||
case ActionType.Use:
|
||||
handler.InteractEntity(entity.ID, InteractType.Interact).Wait();
|
||||
handler.InteractEntityAsync(entity.ID, InteractType.Interact).Wait();
|
||||
return Translations.cmd_entityCmd_used;
|
||||
case ActionType.List:
|
||||
return GetEntityInfoDetailed(handler, entity);
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
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));
|
||||
else
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
||||
|
|
@ -178,7 +178,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
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));
|
||||
else
|
||||
return r.SetAndReturn(CmdResult.Status.Fail, Translations.cmd_inventory_creative_fail);
|
||||
|
|
@ -279,7 +279,7 @@ namespace MinecraftClient.Commands
|
|||
if (inventory == null)
|
||||
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));
|
||||
else
|
||||
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));
|
||||
var task = handler.DoWindowAction(inventoryId.Value, slot, actionType);
|
||||
var task = handler.DoWindowActionAsync(inventoryId.Value, slot, actionType);
|
||||
task.Wait();
|
||||
return r.SetAndReturn(task.Result);
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ namespace MinecraftClient.Commands
|
|||
if (!inventory.Items.ContainsKey(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)
|
||||
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 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));
|
||||
}
|
||||
|
||||
|
|
@ -162,7 +162,7 @@ namespace MinecraftClient.Commands
|
|||
|
||||
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()));
|
||||
else
|
||||
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 (current.ToFloor() == goal.ToFloor())
|
||||
handler.MoveTo(goal, allowDirectTeleport: true);
|
||||
else if (!handler.MoveTo(goal, allowUnsafe: takeRisk))
|
||||
handler.MoveToAsync(goal, allowDirectTeleport: true).Wait();
|
||||
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.Done, string.Format(Translations.cmd_move_walk, goal, current));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace MinecraftClient.Commands
|
|||
private int DoRespawn(CmdResult r)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.SendRespawnPacket().Wait();
|
||||
handler.SendRespawnPacketAsync().Wait();
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ namespace MinecraftClient.Commands
|
|||
private int DoSendText(CmdResult r, string command)
|
||||
{
|
||||
McClient handler = CmdResult.currentHandler!;
|
||||
handler.SendText(command).Wait();
|
||||
handler.SendTextAsync(command).Wait();
|
||||
return r.SetAndReturn(CmdResult.Status.Done);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ namespace MinecraftClient.Commands
|
|||
McClient handler = CmdResult.currentHandler!;
|
||||
if (sneaking)
|
||||
{
|
||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StopSneaking).Result;
|
||||
var result = handler.SendEntityActionAsync(Protocol.EntityActionType.StopSneaking).Result;
|
||||
if (result)
|
||||
sneaking = false;
|
||||
if (result)
|
||||
|
|
@ -52,7 +52,7 @@ namespace MinecraftClient.Commands
|
|||
}
|
||||
else
|
||||
{
|
||||
var result = handler.SendEntityAction(Protocol.EntityActionType.StartSneaking).Result;
|
||||
var result = handler.SendEntityActionAsync(Protocol.EntityActionType.StartSneaking).Result;
|
||||
if (result)
|
||||
sneaking = true;
|
||||
if (result)
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ namespace MinecraftClient.Commands
|
|||
if (!handler.GetInventoryEnabled())
|
||||
return r.SetAndReturn(Status.FailNeedInventory);
|
||||
|
||||
handler.UseItemOnHand().Wait();
|
||||
handler.UseItemOnHandAsync().Wait();
|
||||
return r.SetAndReturn(Status.Done, Translations.cmd_useitem_use);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace MinecraftClient.Commands
|
|||
Location current = handler.GetCurrentLocation();
|
||||
block = block.ToAbsolute(current).ToFloor();
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
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>
|
||||
/// Represents a Minecraft effects
|
||||
/// </summary>
|
||||
public enum Effects
|
||||
public enum EffectType
|
||||
{
|
||||
Speed = 1,
|
||||
Slowness = 2,
|
||||
|
|
@ -1,9 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
using MinecraftClient.Protocol.Message;
|
||||
|
||||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.EntityHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an entity evolving into a Minecraft world
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.EntityHandler
|
||||
{
|
||||
public enum EntityPose
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.EntityHandler
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents Minecraft Entity Types
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.EntityHandler
|
||||
{
|
||||
public static class EntityTypeExtensions
|
||||
{
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
namespace MinecraftClient.Mapping
|
||||
namespace MinecraftClient.EntityHandler
|
||||
{
|
||||
public enum InteractType
|
||||
{
|
||||
|
|
@ -39,8 +39,8 @@ namespace MinecraftClient.Inventory
|
|||
if (ValidateSlots(source, dest, destContainer) &&
|
||||
HasItem(source) &&
|
||||
((destContainer != null && !HasItem(dest, destContainer)) || (destContainer == null && !HasItem(dest))))
|
||||
return mc.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowAction(destContainer == null ? c.ID : destContainer.ID, dest, WindowActionType.LeftClick).Result;
|
||||
return mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowActionAsync(destContainer == null ? c.ID : destContainer.ID, dest, WindowActionType.LeftClick).Result;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
|
@ -57,9 +57,9 @@ namespace MinecraftClient.Inventory
|
|||
if (ValidateSlots(slot1, slot2, destContainer) &&
|
||||
HasItem(slot1) &&
|
||||
(destContainer != null && HasItem(slot2, destContainer) || (destContainer == null && HasItem(slot2))))
|
||||
return mc.DoWindowAction(c.ID, slot1, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowAction(destContainer == null ? c.ID : destContainer.ID, slot2, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowAction(c.ID, slot1, WindowActionType.LeftClick).Result;
|
||||
return mc.DoWindowActionAsync(c.ID, slot1, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowActionAsync(destContainer == null ? c.ID : destContainer.ID, slot2, WindowActionType.LeftClick).Result
|
||||
&& mc.DoWindowActionAsync(c.ID, slot1, WindowActionType.LeftClick).Result;
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
|
@ -104,14 +104,14 @@ namespace MinecraftClient.Inventory
|
|||
break;
|
||||
}
|
||||
}
|
||||
mc.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Wait(); // grab item
|
||||
mc.DoWindowAction(c.ID, -999, startDragging).Wait();
|
||||
mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Wait(); // grab item
|
||||
mc.DoWindowActionAsync(c.ID, -999, startDragging).Wait();
|
||||
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.DoWindowAction(c.ID, source, WindowActionType.LeftClick).Wait(); // put down item left (if any)
|
||||
mc.DoWindowActionAsync(c.ID, -999, endDragging).Wait();
|
||||
mc.DoWindowActionAsync(c.ID, source, WindowActionType.LeftClick).Wait(); // put down item left (if any)
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
|
|
|
|||
|
|
@ -78,17 +78,17 @@
|
|||
|
||||
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)
|
||||
{
|
||||
ConsoleIO.WriteLineFormatted(msg);
|
||||
ConsoleIO.WriteLineFormatted(msg, true);
|
||||
}
|
||||
|
||||
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 MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
namespace MinecraftClient.Mapping.EntityPalettes
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System.Collections.Generic;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
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>
|
||||
/// <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>
|
||||
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();
|
||||
Task<Queue<Location>?> pathfindingTask = Task.Factory.StartNew(() => Movement.CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token));
|
||||
pathfindingTask.Wait(timeout);
|
||||
if (!pathfindingTask.IsCompleted)
|
||||
{
|
||||
cts.Cancel();
|
||||
pathfindingTask.Wait();
|
||||
}
|
||||
return pathfindingTask.Result;
|
||||
CancellationTokenSource cts = new(timeout);
|
||||
return await Task.Run(() => { return CalculatePath(world, start, goal, allowUnsafe, maxOffset, minOffset, cts.Token); }, cts.Token);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using MinecraftClient.EntityHandler;
|
||||
|
||||
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 string settingsIniPath = "MinecraftClient.ini";
|
||||
|
||||
private static int CurrentThreadId;
|
||||
private static bool RestartKeepSettings = false;
|
||||
private static int RestartAfter = -1, Exitcode = 0;
|
||||
|
||||
|
|
@ -93,6 +92,8 @@ namespace MinecraftClient
|
|||
if (BuildInfo != null)
|
||||
ConsoleIO.WriteLineFormatted("§8" + BuildInfo);
|
||||
|
||||
ConsoleIO.WriteLine("\u001b[33m\u001b[46m▀\u001b[0m");
|
||||
|
||||
string? specifiedSettingFile = null;
|
||||
if (args.Length >= 1 && File.Exists(args[0]) && Settings.ToLowerIfNeed(Path.GetExtension(args[0])) == ".ini")
|
||||
{
|
||||
|
|
@ -194,8 +195,6 @@ namespace MinecraftClient
|
|||
|
||||
startupargs = args;
|
||||
|
||||
CurrentThreadId = Environment.CurrentManagedThreadId;
|
||||
|
||||
// Check for updates
|
||||
AsyncTaskHandler.CheckUpdate = Task.Run(async () =>
|
||||
{
|
||||
|
|
@ -419,7 +418,6 @@ namespace MinecraftClient
|
|||
}
|
||||
else if (!loadSucceed)
|
||||
{
|
||||
ConsoleInteractive.ConsoleReader.StopReadThread();
|
||||
while (true)
|
||||
{
|
||||
ConsoleIO.WriteLine(string.Empty);
|
||||
|
|
@ -724,6 +722,7 @@ namespace MinecraftClient
|
|||
var getServerInfoTask = GetServerInfoAsync(loginHttpClient, loginTask);
|
||||
var refreshPlayerKeyTask = RefreshPlayerKeyPair(loginHttpClient, loginTask);
|
||||
|
||||
// Todo: Detailed status display of login steps.
|
||||
(result, session, playerKeyPair) = await loginTask;
|
||||
if (result == ProtocolHandler.LoginResult.Success && session != null)
|
||||
{
|
||||
|
|
@ -808,11 +807,6 @@ namespace MinecraftClient
|
|||
}
|
||||
}
|
||||
|
||||
public static int GetMainThreadId()
|
||||
{
|
||||
return CurrentThreadId;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reloads settings
|
||||
/// </summary>
|
||||
|
|
@ -988,7 +982,7 @@ namespace MinecraftClient
|
|||
public static Type[] GetTypesInNamespace(string nameSpace, Assembly? assembly = null)
|
||||
{
|
||||
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>
|
||||
|
|
@ -998,7 +992,7 @@ namespace MinecraftClient
|
|||
{
|
||||
if (typeof(Program)
|
||||
.Assembly
|
||||
.GetCustomAttributes(typeof(System.Reflection.AssemblyConfigurationAttribute), false)
|
||||
.GetCustomAttributes(typeof(AssemblyConfigurationAttribute), false)
|
||||
.FirstOrDefault() is AssemblyConfigurationAttribute attribute)
|
||||
BuildInfo = attribute.Configuration;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ using System.IO;
|
|||
using System.Runtime.CompilerServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
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 0x03:
|
||||
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 0x05: await ReadData(6); await ReadNextItemSlot(); break;
|
||||
case 0x06: await ReadData(12); break;
|
||||
|
|
@ -196,7 +196,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case 0xC9:
|
||||
string name = await ReadNextString(); bool online = await ReadNextByte() != 0x00; await ReadData(2);
|
||||
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;
|
||||
case 0xCA: if (protocolversion >= 72) { await ReadData(9); } else await ReadData(3); break;
|
||||
case 0xCB:
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ using System.Threading;
|
|||
using System.Threading.Tasks;
|
||||
using MinecraftClient.Commands;
|
||||
using MinecraftClient.Crypto;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Inventory.ItemPalettes;
|
||||
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_2_Version = 760;
|
||||
|
||||
private ulong CurrentTick = 0;
|
||||
|
||||
private int autocomplete_transaction_id = 0;
|
||||
private readonly Dictionary<int, short> window_actions = new();
|
||||
private bool login_phase = true;
|
||||
|
|
@ -218,6 +221,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
while (await periodicTimer.WaitForNextTickAsync(CancelToken) && !CancelToken.IsCancellationRequested)
|
||||
{
|
||||
++CurrentTick;
|
||||
try
|
||||
{
|
||||
await handler.OnUpdate();
|
||||
|
|
@ -226,7 +230,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
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)
|
||||
ConsoleIO.WriteLine(e.StackTrace);
|
||||
}
|
||||
|
|
@ -314,7 +318,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
await SendPacket(PacketTypesOut.Pong, packetData);
|
||||
break;
|
||||
case PacketTypesIn.JoinGame:
|
||||
Task OnGameJoinedTask = handler.OnGameJoined();
|
||||
Task OnGameJoinedTask = handler.OnGameJoinedAsync();
|
||||
|
||||
int playerEntityID = await dataTypes.ReadNextIntAsync(packetData);
|
||||
handler.OnReceivePlayerEntityID(playerEntityID);
|
||||
|
|
@ -439,7 +443,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
else
|
||||
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
|
||||
{
|
||||
|
|
@ -477,7 +481,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
|
||||
ChatMessage chat = new(signedChat, true, messageType, senderUUID, unsignedChatContent, senderDisplayName, senderTeamName, timestamp, messageSignature, verifyResult);
|
||||
handler.OnTextReceived(chat);
|
||||
await handler.OnTextReceivedAsync(chat);
|
||||
}
|
||||
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);
|
||||
if (isOnlineMode && !chat.LacksSender())
|
||||
await Acknowledge(chat);
|
||||
handler.OnTextReceived(chat);
|
||||
await handler.OnTextReceivedAsync(chat);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.CombatEvent:
|
||||
|
|
@ -567,7 +571,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
await dataTypes.SkipNextVarIntAsync(packetData);
|
||||
|
||||
handler.OnPlayerKilled(
|
||||
await handler.OnPlayerKilledAsync(
|
||||
await dataTypes.ReadNextIntAsync(packetData),
|
||||
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
||||
);
|
||||
|
|
@ -578,7 +582,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
case PacketTypesIn.DeathCombatEvent:
|
||||
await dataTypes.SkipNextVarIntAsync(packetData);
|
||||
|
||||
handler.OnPlayerKilled(
|
||||
await handler.OnPlayerKilledAsync(
|
||||
await dataTypes.ReadNextIntAsync(packetData),
|
||||
ChatParser.ParseText(await dataTypes.ReadNextStringAsync(packetData))
|
||||
);
|
||||
|
|
@ -673,7 +677,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
await dataTypes.SkipNextLocationAsync(packetData); // Death location
|
||||
}
|
||||
}
|
||||
handler.OnRespawn();
|
||||
await handler.OnRespawnAsync();
|
||||
break;
|
||||
case PacketTypesIn.PlayerPositionAndLook:
|
||||
{
|
||||
|
|
@ -907,7 +911,21 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
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;
|
||||
case PacketTypesIn.TradeList:
|
||||
if (protocolVersion >= MC_1_14_Version && handler.GetInventoryEnabled())
|
||||
|
|
@ -985,7 +1003,20 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
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;
|
||||
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;
|
||||
case 0x01: //Update gamemode
|
||||
await handler.OnGamemodeUpdate(uuid, await dataTypes.ReadNextVarIntAsync(packetData));
|
||||
break;
|
||||
case 0x02: //Update latency
|
||||
int latency = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
handler.OnLatencyUpdate(uuid, latency); //Update latency;
|
||||
await handler.OnLatencyUpdate(uuid, latency); //Update latency;
|
||||
break;
|
||||
case 0x03: //Update display name
|
||||
if (await dataTypes.ReadNextBoolAsync(packetData))
|
||||
|
|
@ -1273,7 +1304,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
break;
|
||||
case 0x04: //Player Leave
|
||||
handler.OnPlayerLeave(uuid);
|
||||
await handler.OnPlayerLeaveAsync(uuid);
|
||||
break;
|
||||
default:
|
||||
//Unknown player list item type
|
||||
|
|
@ -1288,8 +1319,9 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
short ping = await dataTypes.ReadNextShortAsync(packetData);
|
||||
Guid FakeUUID = new(MD5.HashData(Encoding.UTF8.GetBytes(name)).Take(16).ToArray());
|
||||
if (online)
|
||||
handler.OnPlayerJoin(new PlayerInfo(name, FakeUUID));
|
||||
else handler.OnPlayerLeave(FakeUUID);
|
||||
await handler.OnPlayerJoinAsync(new PlayerInfo(name, FakeUUID));
|
||||
else
|
||||
await handler.OnPlayerLeaveAsync(FakeUUID);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.TabComplete:
|
||||
|
|
@ -1344,7 +1376,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
string title = await dataTypes.ReadNextStringAsync(packetData);
|
||||
byte slots = await dataTypes.ReadNextByteAsync(packetData);
|
||||
Container inventory = new(windowID, inventoryType, ChatParser.ParseText(title));
|
||||
handler.OnInventoryOpen(windowID, inventory);
|
||||
await handler.OnInventoryOpenAsync(windowID, inventory);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -1353,7 +1385,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
int windowType = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
string title = await dataTypes.ReadNextStringAsync(packetData);
|
||||
Container inventory = new(windowID, windowType, ChatParser.ParseText(title));
|
||||
handler.OnInventoryOpen(windowID, inventory);
|
||||
await handler.OnInventoryOpenAsync(windowID, inventory);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1362,7 +1394,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
byte windowID = await dataTypes.ReadNextByteAsync(packetData);
|
||||
lock (window_actions) { window_actions[windowID] = 0; }
|
||||
handler.OnInventoryClose(windowID);
|
||||
await handler.OnInventoryCloseAsync(windowID);
|
||||
}
|
||||
break;
|
||||
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
|
||||
await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||
|
||||
handler.OnWindowItems(windowId, inventorySlots, stateId);
|
||||
await handler.OnWindowItemsAsync(windowId, inventorySlots, stateId);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.WindowProperty:
|
||||
|
|
@ -1403,7 +1435,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
short propertyId = await dataTypes.ReadNextShortAsync(packetData);
|
||||
short propertyValue = await dataTypes.ReadNextShortAsync(packetData);
|
||||
|
||||
handler.OnWindowProperties(containerId, propertyId, propertyValue);
|
||||
await handler.OnWindowPropertiesAsync(containerId, propertyId, propertyValue);
|
||||
break;
|
||||
case PacketTypesIn.SetSlot:
|
||||
if (handler.GetInventoryEnabled())
|
||||
|
|
@ -1414,7 +1446,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
stateId = await dataTypes.ReadNextVarIntAsync(packetData); // State ID - 1.17.1 and above
|
||||
short slotID = await dataTypes.ReadNextShortAsync(packetData);
|
||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||
handler.OnSetSlot(windowID, slotID, item, stateId);
|
||||
await handler.OnSetSlotAsync(windowID, slotID, item, stateId);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.WindowConfirmation:
|
||||
|
|
@ -1452,7 +1484,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (handler.GetEntityHandlingEnabled())
|
||||
{
|
||||
Entity entity = await dataTypes.ReadNextEntity(packetData, entityPalette, false);
|
||||
handler.OnSpawnEntity(entity);
|
||||
await handler.OnSpawnEntity(entity);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityEquipment:
|
||||
|
|
@ -1469,14 +1501,14 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
hasNext = bitsData >> 7 == 1;
|
||||
int slot2 = bitsData >> 1;
|
||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||
handler.OnEntityEquipment(entityid, slot2, item);
|
||||
await handler.OnEntityEquipment(entityid, slot2, item);
|
||||
} while (hasNext);
|
||||
}
|
||||
else
|
||||
{
|
||||
int slot2 = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
Item? item = await dataTypes.ReadNextItemSlotAsync(packetData, itemPalette);
|
||||
handler.OnEntityEquipment(entityid, slot2, item);
|
||||
await handler.OnEntityEquipment(entityid, slot2, item);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1487,7 +1519,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
// packet before 1.15 has metadata at the end
|
||||
// this is not handled in dataTypes.ReadNextEntity()
|
||||
// we are simply ignoring leftover data in packet
|
||||
handler.OnSpawnEntity(entity);
|
||||
await handler.OnSpawnEntity(entity);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.SpawnPlayer:
|
||||
|
|
@ -1503,17 +1535,17 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
|
||||
Location EntityLocation = new(X, Y, Z);
|
||||
|
||||
handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch);
|
||||
await handler.OnSpawnPlayer(EntityID, UUID, EntityLocation, Yaw, Pitch);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityEffect:
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
{
|
||||
int entityid = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
Effects effect = Effects.Speed;
|
||||
EffectType effectType = EffectType.Speed;
|
||||
int effectId = protocolVersion >= MC_1_18_2_Version ?
|
||||
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 duration = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
|
|
@ -1529,7 +1561,19 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
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;
|
||||
|
|
@ -1544,7 +1588,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
entityList[i] = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
}
|
||||
handler.OnDestroyEntities(entityList);
|
||||
await handler.OnDestroyEntities(entityList);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityPosition:
|
||||
|
|
@ -1558,7 +1602,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
DeltaX /= 128 * 32;
|
||||
DeltaY /= 128 * 32;
|
||||
DeltaZ /= 128 * 32;
|
||||
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||
await handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityPositionAndRotation:
|
||||
|
|
@ -1574,7 +1618,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
DeltaX /= 128 * 32;
|
||||
DeltaY /= 128 * 32;
|
||||
DeltaZ /= 128 * 32;
|
||||
handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||
await handler.OnEntityPosition(EntityID, DeltaX, DeltaY, DeltaZ, OnGround);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityProperties:
|
||||
|
|
@ -1609,7 +1653,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
if (op2.Count > 0) _value *= op2.Aggregate((a, _x) => a * _x);
|
||||
keys.Add(_key, _value);
|
||||
}
|
||||
handler.OnEntityProperties(EntityID, keys);
|
||||
await handler.OnEntityProperties(EntityID, keys);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.EntityMetadata:
|
||||
|
|
@ -1641,20 +1685,20 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
int entityId = await dataTypes.ReadNextIntAsync(packetData);
|
||||
byte status = await dataTypes.ReadNextByteAsync(packetData);
|
||||
handler.OnEntityStatus(entityId, status);
|
||||
await handler.OnEntityStatus(entityId, status);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.TimeUpdate:
|
||||
long WorldAge = await dataTypes.ReadNextLongAsync(packetData);
|
||||
long TimeOfday = await dataTypes.ReadNextLongAsync(packetData);
|
||||
handler.OnTimeUpdate(WorldAge, TimeOfday);
|
||||
await handler.OnTimeUpdate(WorldAge, TimeOfday);
|
||||
break;
|
||||
case PacketTypesIn.SystemChat:
|
||||
string systemMessage = await dataTypes.ReadNextStringAsync(packetData);
|
||||
int msgType = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
if (msgType == 1 && !Config.Main.Advanced.ShowSystemMessages)
|
||||
break;
|
||||
handler.OnTextReceived(new(systemMessage, true, msgType, Guid.Empty, true));
|
||||
await handler.OnTextReceivedAsync(new(systemMessage, true, msgType, Guid.Empty, true));
|
||||
break;
|
||||
case PacketTypesIn.EntityTeleport:
|
||||
if (handler.GetEntityHandlingEnabled())
|
||||
|
|
@ -1666,7 +1710,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
byte EntityYaw = await dataTypes.ReadNextByteAsync(packetData);
|
||||
byte EntityPitch = await dataTypes.ReadNextByteAsync(packetData);
|
||||
bool OnGround = await dataTypes.ReadNextBoolAsync(packetData);
|
||||
handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround);
|
||||
await handler.OnEntityTeleport(EntityID, X, Y, Z, OnGround);
|
||||
}
|
||||
break;
|
||||
case PacketTypesIn.UpdateHealth:
|
||||
|
|
@ -1677,13 +1721,13 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
else
|
||||
food = await dataTypes.ReadNextShortAsync(packetData);
|
||||
await dataTypes.SkipNextFloatAsync(packetData); // Food Saturation
|
||||
handler.OnUpdateHealth(health, food);
|
||||
await handler.OnUpdateHealth(health, food);
|
||||
break;
|
||||
case PacketTypesIn.SetExperience:
|
||||
float experiencebar = await dataTypes.ReadNextFloatAsync(packetData);
|
||||
int level = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
int totalexperience = await dataTypes.ReadNextVarIntAsync(packetData);
|
||||
handler.OnSetExperience(experiencebar, level, totalexperience);
|
||||
await handler.OnSetExperience(experiencebar, level, totalexperience);
|
||||
break;
|
||||
case PacketTypesIn.Explosion:
|
||||
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 playerVelocityZ = await dataTypes.ReadNextFloatAsync(packetData);
|
||||
|
||||
handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
||||
await handler.OnExplosion(explosionLocation, explosionStrength, explosionBlockCount);
|
||||
break;
|
||||
case PacketTypesIn.HeldItemChange:
|
||||
byte slot = await dataTypes.ReadNextByteAsync(packetData);
|
||||
handler.OnHeldItemChange(slot);
|
||||
await handler.OnHeldItemChange(slot);
|
||||
break;
|
||||
case PacketTypesIn.ScoreboardObjective:
|
||||
string objectivename = await dataTypes.ReadNextStringAsync(packetData);
|
||||
|
|
@ -1771,6 +1815,15 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public ulong GetCurrentTick()
|
||||
{
|
||||
return CurrentTick;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disconnect from the server, cancel network reading.
|
||||
/// </summary>
|
||||
|
|
@ -1805,8 +1858,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
{
|
||||
if (handler.GetNetworkPacketCaptureEnabled())
|
||||
{
|
||||
List<byte> clone = packetData.ToList();
|
||||
handler.OnNetworkPacket(packetID, clone, login_phase, false);
|
||||
await handler.OnNetworkPacketAsync(packetID, packetData.ToArray(), login_phase, false);
|
||||
}
|
||||
// log.Info("[C -> S] Sending packet " + packetID + " > " + dataTypes.ByteArrayToString(packetData.ToArray()));
|
||||
|
||||
|
|
@ -2248,7 +2300,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
/// </summary>
|
||||
/// <param name="acknowledgment">Message acknowledgment</param>
|
||||
/// <returns>True if properly sent</returns>
|
||||
public async Task<bool> SendMessageAcknowledgment(LastSeenMessageList.Acknowledgment acknowledgment)
|
||||
public async Task<bool> SendMessageAckAsync(LastSeenMessageList.Acknowledgment acknowledgment)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
@ -2279,7 +2331,7 @@ namespace MinecraftClient.Protocol.Handlers
|
|||
lastReceivedMessage = null;
|
||||
|
||||
if (pendingAcknowledgments++ > 64)
|
||||
await SendMessageAcknowledgment(ConsumeAcknowledgment());
|
||||
await SendMessageAckAsync(ConsumeAcknowledgment());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Logger;
|
||||
using MinecraftClient.Mapping;
|
||||
|
|
@ -53,18 +54,18 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="packetData">A copy of Packet Data</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>
|
||||
void OnNetworkPacket(int packetID, List<byte> packetData, bool isLogin, bool isInbound);
|
||||
Task OnNetworkPacketAsync(int packetID, byte[] packetData, bool isLogin, bool isInbound);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a server was successfully joined
|
||||
/// </summary>
|
||||
Task OnGameJoined();
|
||||
Task OnGameJoinedAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Received chat/system message from the server
|
||||
/// </summary>
|
||||
/// <param name="message">Message received</param>
|
||||
public void OnTextReceived(ChatMessage message);
|
||||
Task OnTextReceivedAsync(ChatMessage message);
|
||||
|
||||
/// <summary>
|
||||
/// Will be called every animations of the hit and place block
|
||||
|
|
@ -90,7 +91,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <summary>
|
||||
/// This method is called when the protocol handler receives a title
|
||||
/// </summary>
|
||||
void OnTitle(int action, string titletext, string subtitletext, string actionbartext, int fadein, int stay, int fadeout, string json);
|
||||
Task OnTitle(TitlePacket title);
|
||||
|
||||
/// <summary>
|
||||
/// Called when receiving a connection keep-alive from the server
|
||||
|
|
@ -116,36 +117,36 @@ namespace MinecraftClient.Protocol
|
|||
/// <summary>
|
||||
/// Called when an inventory is opened
|
||||
/// </summary>
|
||||
void OnInventoryOpen(int inventoryID, Container inventory);
|
||||
Task OnInventoryOpenAsync(int inventoryID, Container inventory);
|
||||
|
||||
/// <summary>
|
||||
/// Called when an inventory is closed
|
||||
/// </summary>
|
||||
void OnInventoryClose(int inventoryID);
|
||||
Task OnInventoryCloseAsync(int inventoryID);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the player respawns, which happens on login, respawn and world change.
|
||||
/// </summary>
|
||||
void OnRespawn();
|
||||
Task OnRespawnAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Triggered when a new player joins the game
|
||||
/// </summary>
|
||||
/// <param name="player">player info</param>
|
||||
public void OnPlayerJoin(PlayerInfo player);
|
||||
Task OnPlayerJoinAsync(PlayerInfo player);
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when a player has left the game
|
||||
/// </summary>
|
||||
/// <param name="uuid">UUID of the player</param>
|
||||
void OnPlayerLeave(Guid uuid);
|
||||
Task OnPlayerLeaveAsync(Guid uuid);
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when a player has been killed by another entity
|
||||
/// </summary>
|
||||
/// <param name="killerEntityId">Killer's entity if</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>
|
||||
/// 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);
|
||||
|
||||
/// <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
|
||||
/// </summary>
|
||||
Task OnUpdate();
|
||||
|
|
@ -171,14 +172,14 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="channel">The channel to register.</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>
|
||||
/// Unregisters the given plugin channel for the given bot.
|
||||
/// </summary>
|
||||
/// <param name="channel">The channel to unregister.</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>
|
||||
/// 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="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>
|
||||
Task<bool> SendPluginChannelMessage(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
||||
Task<bool> SendPluginChannelMessageAsync(string channel, byte[] data, bool sendEvenIfNotRegistered = false);
|
||||
|
||||
/// <summary>
|
||||
/// Called when a plugin channel message was sent from the server.
|
||||
|
|
@ -201,7 +202,7 @@ namespace MinecraftClient.Protocol
|
|||
/// Called when an entity has spawned
|
||||
/// </summary>
|
||||
/// <param name="entity">Spawned entity</param>
|
||||
void OnSpawnEntity(Entity entity);
|
||||
Task OnSpawnEntity(Entity entity);
|
||||
|
||||
/// <summary>
|
||||
/// Called when an entity has spawned
|
||||
|
|
@ -209,7 +210,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <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="item">Item/param>
|
||||
void OnEntityEquipment(int entityid, int slot, Item? item);
|
||||
Task OnEntityEquipment(int entityid, int slot, Item? item);
|
||||
|
||||
/// <summary>
|
||||
/// 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="yaw">Player head yaw</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>
|
||||
/// Called when entities have despawned
|
||||
/// </summary>
|
||||
/// <param name="EntityID">List of Entity ID that have despawned</param>
|
||||
void OnDestroyEntities(int[] EntityID);
|
||||
Task OnDestroyEntities(int[] EntityID);
|
||||
|
||||
/// <summary>
|
||||
/// Called when an entity moved by coordinate offset
|
||||
|
|
@ -235,7 +236,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="Dy">Y offset</param>
|
||||
/// <param name="Dz">Z offset</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>
|
||||
/// Called when an entity moved to fixed coordinates
|
||||
|
|
@ -245,28 +246,28 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="Dy">Y</param>
|
||||
/// <param name="Dz">Z</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>
|
||||
/// Called when additional properties have been received for an entity
|
||||
/// </summary>
|
||||
/// <param name="EntityID">Entity ID</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>
|
||||
/// Called when the status of an entity have been changed
|
||||
/// </summary>
|
||||
/// <param name="entityID">Entity ID</param>
|
||||
/// <param name="status">Status ID</param>
|
||||
void OnEntityStatus(int entityID, byte status);
|
||||
Task OnEntityStatus(int entityID, byte status);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the world age has been updated
|
||||
/// </summary>
|
||||
/// <param name="WorldAge">World age</param>
|
||||
/// <param name="TimeOfDay">Time of Day</param>
|
||||
void OnTimeUpdate(long worldAge, long timeOfDay);
|
||||
Task OnTimeUpdate(long worldAge, long timeOfDay);
|
||||
|
||||
/// <summary>
|
||||
/// When received window properties from server.
|
||||
|
|
@ -275,7 +276,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="inventoryID">Inventory ID</param>
|
||||
/// <param name="propertyId">Property ID</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>
|
||||
/// Called when inventory items have been received
|
||||
|
|
@ -283,7 +284,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="inventoryID">Inventory ID</param>
|
||||
/// <param name="itemList">Item list</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>
|
||||
/// 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="item">Item (may be null for empty slot)</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>
|
||||
/// Called when player health or hunger changed.
|
||||
/// </summary>
|
||||
/// <param name="health"></param>
|
||||
/// <param name="food"></param>
|
||||
void OnUpdateHealth(float health, int food);
|
||||
Task OnUpdateHealth(float health, int food);
|
||||
|
||||
/// <summary>
|
||||
/// Called when the health of an entity changed
|
||||
|
|
@ -321,7 +322,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="location">Explosion location</param>
|
||||
/// <param name="strength">Explosion strength</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>
|
||||
/// Called when a player's game mode has changed
|
||||
|
|
@ -335,7 +336,7 @@ namespace MinecraftClient.Protocol
|
|||
/// </summary>
|
||||
/// <param name="uuid">Affected player's UUID</param>
|
||||
/// <param name="latency">latency</param>
|
||||
void OnLatencyUpdate(Guid uuid, int latency);
|
||||
Task OnLatencyUpdate(Guid uuid, int latency);
|
||||
|
||||
/// <summary>
|
||||
/// Called when Experience bar is updated
|
||||
|
|
@ -343,14 +344,14 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="Experiencebar">Experience bar level</param>
|
||||
/// <param name="Level">Player Level</param>
|
||||
/// <param name="TotalExperience">Total experience</param>
|
||||
void OnSetExperience(float Experiencebar, int Level, int TotalExperience);
|
||||
Task OnSetExperience(float Experiencebar, int Level, int TotalExperience);
|
||||
|
||||
/// <summary>
|
||||
/// Called when client need to change slot.
|
||||
/// </summary>
|
||||
/// <remarks>Used for setting player slot after joining game</remarks>
|
||||
/// <param name="slot"></param>
|
||||
void OnHeldItemChange(byte slot);
|
||||
Task OnHeldItemChange(byte slot);
|
||||
|
||||
/// <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
|
||||
|
|
@ -366,7 +367,7 @@ namespace MinecraftClient.Protocol
|
|||
/// <param name="mapCoulmnX">x offset of the westernmost column</param>
|
||||
/// <param name="mapRowZ">z offset of the northernmost row</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>
|
||||
/// 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="hasFactorData">has factor data</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>
|
||||
/// Called when coreboardObjective
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
private const int BufferSize = 1024;
|
||||
|
||||
public Socket Client;
|
||||
public bool HwAccelerateEnable { init; get; }
|
||||
private bool inStreamEnded = false;
|
||||
|
||||
private readonly IAesHandler Aes;
|
||||
|
|
@ -44,11 +45,20 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
AesBufSend = new byte[BlockSize];
|
||||
|
||||
if (FasterAesX86.IsSupported())
|
||||
{
|
||||
HwAccelerateEnable = true;
|
||||
Aes = new FasterAesX86(key);
|
||||
else if (FasterAesArm.IsSupported())
|
||||
}
|
||||
else if (false && FasterAesArm.IsSupported()) // Further testing required
|
||||
{
|
||||
HwAccelerateEnable = true;
|
||||
Aes = new FasterAesArm(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
HwAccelerateEnable = false;
|
||||
Aes = new BasicAes(key);
|
||||
}
|
||||
|
||||
key.CopyTo(InputBuf.Slice(0, BlockSize));
|
||||
key.CopyTo(OutputBuf.Slice(0, BlockSize));
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
public int CompressionThreshold { get; set; } = 0;
|
||||
|
||||
|
||||
private SemaphoreSlim SendSemaphore = new SemaphoreSlim(1, 1);
|
||||
private SemaphoreSlim SendSemaphore = new(1, 1);
|
||||
|
||||
private Task LastSendTask = Task.CompletedTask;
|
||||
|
||||
|
|
@ -78,7 +78,8 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
/// <param name="buffer">data to send</param>
|
||||
public async Task SendAsync(Memory<byte> buffer, CancellationToken cancellationToken = default)
|
||||
{
|
||||
await SendSemaphore.WaitAsync();
|
||||
await SendSemaphore.WaitAsync(cancellationToken);
|
||||
if (cancellationToken.IsCancellationRequested) return;
|
||||
await LastSendTask;
|
||||
LastSendTask = WriteStream.WriteAsync(buffer, cancellationToken).AsTask();
|
||||
SendSemaphore.Release();
|
||||
|
|
@ -86,7 +87,6 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
|
||||
public async Task<Tuple<int, PacketStream>> GetNextPacket(bool handleCompress, CancellationToken cancellationToken = default)
|
||||
{
|
||||
// ConsoleIO.WriteLine("GetNextPacket");
|
||||
if (packetStream != null)
|
||||
{
|
||||
await packetStream.DisposeAsync();
|
||||
|
|
@ -105,9 +105,18 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
ZlibBaseStream zlibBaseStream = new(AesStream ?? ReadStream, packetSize: packetSize - readed);
|
||||
ZLibStream zlibStream = new(zlibBaseStream, CompressionMode.Decompress, leaveOpen: false);
|
||||
|
||||
if (AesStream == null || AesStream.HwAccelerateEnable)
|
||||
{
|
||||
zlibBaseStream.BufferSize = 64;
|
||||
(packetID, readed) = await ReceiveVarIntRaw(zlibStream, cancellationToken);
|
||||
zlibBaseStream.BufferSize = 1024;
|
||||
}
|
||||
else
|
||||
{
|
||||
zlibBaseStream.BufferSize = 16;
|
||||
(packetID, readed) = await ReceiveVarIntRaw(zlibStream, cancellationToken);
|
||||
zlibBaseStream.BufferSize = 512;
|
||||
zlibBaseStream.BufferSize = 256;
|
||||
}
|
||||
|
||||
// ConsoleIO.WriteLine("packetID = " + packetID + ", readed = " + zlibBaseStream.packetReaded + ", size = " + packetSize + " -> " + sizeUncompressed);
|
||||
|
||||
|
|
@ -131,7 +140,7 @@ namespace MinecraftClient.Protocol.PacketPipeline
|
|||
byte[] b = new byte[1];
|
||||
while (true)
|
||||
{
|
||||
await stream.ReadAsync(b);
|
||||
await stream.ReadAsync(b, cancellationToken);
|
||||
i |= (b[0] & 0x7F) << j++ * 7;
|
||||
if (j > 5) throw new OverflowException("VarInt too big");
|
||||
if ((b[0] & 0x80) != 128) break;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace MinecraftClient.Protocol
|
|||
|
||||
// Entity info
|
||||
|
||||
public Mapping.Entity? entity;
|
||||
public EntityHandler.Entity? entity;
|
||||
|
||||
// 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>
|
||||
/// Looks up a localized string similar to Right.
|
||||
/// </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>
|
||||
/// Looks up a localized string similar to [Settings] The language code is invalid!.
|
||||
/// </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>
|
||||
/// Looks up a localized string similar to Settings have been loaded from {0}.
|
||||
/// </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>
|
||||
/// Looks up a localized string similar to Connecting to {0}....
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -2040,4 +2040,20 @@ Logging in...</value>
|
|||
<data name="config.invaild_login_method" xml:space="preserve">
|
||||
<value>[Settings] Only Microsoft accounts support logging in using the browser method.</value>
|
||||
</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>
|
||||
|
|
@ -7,6 +7,7 @@ using System.Text.RegularExpressions;
|
|||
using System.Threading.Tasks;
|
||||
using Brigadier.NET;
|
||||
using MinecraftClient.CommandHandler;
|
||||
using MinecraftClient.EntityHandler;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
using static MinecraftClient.Settings;
|
||||
|
|
@ -37,7 +38,7 @@ namespace MinecraftClient.Scripting
|
|||
//Handler will be automatically set on bot loading, don't worry about this
|
||||
public void SetHandler(McClient handler) { _handler = handler; }
|
||||
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 void UnLoadBot(ChatBot bot) { Handler.BotUnLoad(bot).Wait(); }
|
||||
private McClient? _handler = null;
|
||||
|
|
@ -105,6 +106,12 @@ namespace MinecraftClient.Scripting
|
|||
/// </summary>
|
||||
public virtual void Initialize() { }
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public virtual Tuple<McClientEventType, Func<object?, Task>>[]? InitializeEventCallbacks() { return null; }
|
||||
|
||||
/// <summary>
|
||||
/// This method is called when the bot is being unloaded, you can use it to free up resources like DB connections
|
||||
/// </summary>
|
||||
|
|
@ -260,14 +267,6 @@ namespace MinecraftClient.Scripting
|
|||
/// <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) { }
|
||||
|
||||
/// <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>
|
||||
/// Called when the Latency has been updated for a player
|
||||
/// </summary>
|
||||
|
|
@ -337,7 +336,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="amplifier">effect amplifier</param>
|
||||
/// <param name="duration">effect duration</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>
|
||||
/// Called when a scoreboard objective updated
|
||||
|
|
@ -518,7 +517,7 @@ namespace MinecraftClient.Scripting
|
|||
protected bool SendText(string text, bool sendImmediately = false)
|
||||
{
|
||||
LogToConsole("Sending '" + text + "'");
|
||||
Handler.SendText(text).Wait();
|
||||
Handler.SendTextAsync(text).Wait();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -982,7 +981,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="localVars">Local variables for use in the Script</param>
|
||||
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>
|
||||
|
|
@ -991,7 +990,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="chatBot">ChatBot to load</param>
|
||||
protected void BotLoad(ChatBot chatBot)
|
||||
{
|
||||
Handler.BotLoad(chatBot);
|
||||
Handler.BotLoad(chatBot).Wait();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1037,7 +1036,7 @@ namespace MinecraftClient.Scripting
|
|||
/// </summary>
|
||||
private bool SendEntityAction(Protocol.EntityActionType entityAction)
|
||||
{
|
||||
return Handler.SendEntityAction(entityAction).Result;
|
||||
return Handler.SendEntityActionAsync(entityAction).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1045,7 +1044,7 @@ namespace MinecraftClient.Scripting
|
|||
/// </summary>
|
||||
private async Task<bool> SendEntityActionAsync(Protocol.EntityActionType entityAction)
|
||||
{
|
||||
return await Handler.SendEntityAction(entityAction);
|
||||
return await Handler.SendEntityActionAsync(entityAction);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1056,7 +1055,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="lookAtBlock">Also look at the block before digging</param>
|
||||
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>
|
||||
|
|
@ -1064,7 +1063,7 @@ namespace MinecraftClient.Scripting
|
|||
/// </summary>
|
||||
protected bool SetSlot(int slotNum)
|
||||
{
|
||||
return Handler.ChangeSlot((short)slotNum).Result;
|
||||
return Handler.ChangeSlotAsync((short)slotNum).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1116,7 +1115,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <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)
|
||||
{
|
||||
return Handler.MoveTo(location, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout);
|
||||
return Handler.MoveToAsync(location, allowUnsafe, allowDirectTeleport, maxOffset, minOffset, timeout).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1297,7 +1296,7 @@ namespace MinecraftClient.Scripting
|
|||
protected void RegisterPluginChannel(string channel)
|
||||
{
|
||||
registeredPluginChannels.Add(channel);
|
||||
Handler.RegisterPluginChannel(channel, this).Wait();
|
||||
Handler.RegisterPluginChannelAsync(channel, this).Wait();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1307,7 +1306,7 @@ namespace MinecraftClient.Scripting
|
|||
protected void UnregisterPluginChannel(string channel)
|
||||
{
|
||||
registeredPluginChannels.RemoveAll(chan => chan == channel);
|
||||
Handler.UnregisterPluginChannel(channel, this).Wait();
|
||||
Handler.UnregisterPluginChannelAsync(channel, this).Wait();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1327,7 +1326,7 @@ namespace MinecraftClient.Scripting
|
|||
return false;
|
||||
}
|
||||
}
|
||||
return Handler.SendPluginChannelMessage(channel, data, sendEvenIfNotRegistered).Result;
|
||||
return Handler.SendPluginChannelMessageAsync(channel, data, sendEvenIfNotRegistered).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1349,7 +1348,7 @@ namespace MinecraftClient.Scripting
|
|||
[Obsolete("Prefer using InteractType enum instead of int for interaction type")]
|
||||
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>
|
||||
|
|
@ -1361,7 +1360,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE in case of success</returns>
|
||||
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>
|
||||
|
|
@ -1375,7 +1374,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE if item given successfully</returns>
|
||||
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>
|
||||
|
|
@ -1397,7 +1396,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE if animation successfully done</returns>
|
||||
public bool SendAnimation(Hand hand = Hand.MainHand)
|
||||
{
|
||||
return Handler.DoAnimation((int)hand).Result;
|
||||
return Handler.DoAnimationAsync((int)hand).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1406,7 +1405,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE if successful</returns>
|
||||
protected bool UseItemInHand()
|
||||
{
|
||||
return Handler.UseItemOnHand().Result;
|
||||
return Handler.UseItemOnHandAsync().Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1415,7 +1414,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE if successful</returns>
|
||||
protected bool UseItemInLeftHand()
|
||||
{
|
||||
return Handler.UseItemOnLeftHand().Result;
|
||||
return Handler.UseItemOnOffHandAsync().Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1436,7 +1435,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE if successfully placed</returns>
|
||||
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>
|
||||
|
|
@ -1467,7 +1466,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>TRUE in case of success</returns>
|
||||
protected bool WindowAction(int inventoryId, int slot, WindowActionType actionType)
|
||||
{
|
||||
return Handler.DoWindowAction(inventoryId, slot, actionType).Result;
|
||||
return Handler.DoWindowActionAsync(inventoryId, slot, actionType).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1487,7 +1486,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>True if success</returns>
|
||||
protected bool ChangeSlot(short slot)
|
||||
{
|
||||
return Handler.ChangeSlot(slot).Result;
|
||||
return Handler.ChangeSlotAsync(slot).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1518,7 +1517,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="line4"> text1 four</param>
|
||||
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>
|
||||
|
|
@ -1527,7 +1526,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="selectedSlot">Trade slot to select, starts at 0.</param>
|
||||
protected bool SelectTrade(int selectedSlot)
|
||||
{
|
||||
return Handler.SelectTrade(selectedSlot).Result;
|
||||
return Handler.SelectTradeAsync(selectedSlot).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1536,7 +1535,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="entity">player to teleport to</param>
|
||||
protected bool SpectatorTeleport(Entity entity)
|
||||
{
|
||||
return Handler.Spectate(entity).Result;
|
||||
return Handler.SpectateAsync(entity).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1545,7 +1544,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="uuid">uuid of entity to teleport to</param>
|
||||
protected bool SpectatorTeleport(Guid UUID)
|
||||
{
|
||||
return Handler.SpectateByUUID(UUID).Result;
|
||||
return Handler.SpectateByUuidAsync(UUID).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1557,7 +1556,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="flags">command block flags</param>
|
||||
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>
|
||||
|
|
@ -1567,7 +1566,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <returns>True if success</returns>
|
||||
protected bool CloseInventory(int inventoryID)
|
||||
{
|
||||
return Handler.CloseInventory(inventoryID).Result;
|
||||
return Handler.CloseInventoryAsync(inventoryID).Result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -1585,7 +1584,7 @@ namespace MinecraftClient.Scripting
|
|||
protected bool Respawn()
|
||||
{
|
||||
if (Handler.GetHealth() <= 0)
|
||||
return Handler.SendRespawnPacket().Result;
|
||||
return Handler.SendRespawnPacketAsync().Result;
|
||||
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
|
||||
{
|
||||
get { return ChatBotConfigHealper.Config; }
|
||||
set { ChatBotConfigHealper.Config = value; }
|
||||
set { ChatBotConfigHealper.Config = value; ChatBotConfigHealper.Config.OnSettingUpdate(); }
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -797,6 +797,9 @@ namespace MinecraftClient
|
|||
|
||||
public void OnSettingUpdate()
|
||||
{
|
||||
if (General.ConsoleColorMode == ConsoleColorModeType.legacy_4bit)
|
||||
ConsoleIO.WriteLineFormatted("§8" + Translations.config_legacy_color, true);
|
||||
|
||||
// Reader
|
||||
ConsoleInteractive.ConsoleReader.DisplayUesrInput = General.Display_Input;
|
||||
|
||||
|
|
@ -1252,6 +1255,8 @@ namespace MinecraftClient
|
|||
[TomlDoNotInlineObject]
|
||||
public class ChatBotConfig
|
||||
{
|
||||
public void OnSettingUpdate() { }
|
||||
|
||||
[TomlPrecedingComment("$ChatBot.Alerts$")]
|
||||
public ChatBots.Alerts.Configs Alerts
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue