mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
Formatted the code and removed logs from Auto Attack
This commit is contained in:
parent
a4ff7ae438
commit
c6ca3dc13d
117 changed files with 602 additions and 585 deletions
|
|
@ -120,7 +120,7 @@ namespace MinecraftClient.Scripting
|
|||
|
||||
var loc = failure.Location.GetMappedLineSpan();
|
||||
var line = code.Split('\n')[loc.StartLinePosition.Line];
|
||||
|
||||
|
||||
ConsoleIO.WriteLogLine($"[Script] Error in {scriptName}, on line ({line.Trim()}): [{failure.Id}] {failure.GetMessage()}");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -226,7 +226,8 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="pitch">Sound pitch</param>
|
||||
/// <param name="sourceEntity">Source entity for entity-sound packets when tracked</param>
|
||||
public virtual void OnSoundEffect(string? soundName, Location? location, int category, float volume, float pitch,
|
||||
Entity? sourceEntity) { }
|
||||
Entity? sourceEntity)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Called when an entity rotates
|
||||
|
|
@ -405,7 +406,8 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="players">Player/entity names. Present when method is 0, 3, or 4.</param>
|
||||
public virtual void OnTeam(string teamName, byte method, string displayName, byte friendlyFlags,
|
||||
string nameTagVisibility, string collisionRule, int color,
|
||||
string prefix, string suffix, List<string> players) { }
|
||||
string prefix, string suffix, List<string> players)
|
||||
{ }
|
||||
|
||||
/// <summary>
|
||||
/// Called when the client received the Tab Header and Footer
|
||||
|
|
@ -413,7 +415,7 @@ namespace MinecraftClient.Scripting
|
|||
/// <param name="header">Header</param>
|
||||
/// <param name="footer">Footer</param>
|
||||
public virtual void OnTabListHeaderAndFooter(string header, string footer) { }
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Called when an inventory/container was updated by server
|
||||
/// </summary>
|
||||
|
|
@ -1068,7 +1070,7 @@ namespace MinecraftClient.Scripting
|
|||
{
|
||||
Handler.BotLoad(chatBot);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set an App Variable
|
||||
/// </summary>
|
||||
|
|
@ -1079,7 +1081,7 @@ namespace MinecraftClient.Scripting
|
|||
{
|
||||
Config.AppVar.SetVar(name, value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get a value from an App Variable
|
||||
/// </summary>
|
||||
|
|
@ -1089,7 +1091,7 @@ namespace MinecraftClient.Scripting
|
|||
{
|
||||
return Config.AppVar.GetVar(name);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Replaces variables in text with their values from the App Var registry
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
|
|||
var MinecraftClientDll = typeof(Program).Assembly.Location; // The path to MinecraftClient.dll
|
||||
|
||||
// We're on a self-contained binary, so we need to extract the executable to get the assemblies.
|
||||
if (string.IsNullOrEmpty(MinecraftClientDll))
|
||||
if (string.IsNullOrEmpty(MinecraftClientDll))
|
||||
{
|
||||
// Create a temporary file to copy the executable to.
|
||||
var executablePath = Environment.ProcessPath;
|
||||
|
|
@ -86,29 +86,29 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
|
|||
throw new InvalidOperationException("Cannot determine the process path for self-contained scripting extraction.");
|
||||
var tempPath = Path.Combine(Path.GetTempPath(), "mcc-scripting");
|
||||
Directory.CreateDirectory(tempPath);
|
||||
|
||||
|
||||
var tempFile = Path.Combine(tempPath, "mcc-executable");
|
||||
var useExisting = false;
|
||||
|
||||
// Check if we already have the executable in the temporary path.
|
||||
foreach (var file in Directory.EnumerateFiles(tempPath))
|
||||
foreach (var file in Directory.EnumerateFiles(tempPath))
|
||||
{
|
||||
if (file.EndsWith("mcc-executable"))
|
||||
if (file.EndsWith("mcc-executable"))
|
||||
{
|
||||
// Check if the file is the same as the current executable.
|
||||
if (File.ReadAllBytes(file).SequenceEqual(File.ReadAllBytes(executablePath)))
|
||||
if (File.ReadAllBytes(file).SequenceEqual(File.ReadAllBytes(executablePath)))
|
||||
{
|
||||
useExisting = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// If not, refresh the cache.
|
||||
File.Delete(file);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!File.Exists(executablePath))
|
||||
|
||||
if (!File.Exists(executablePath))
|
||||
{
|
||||
throw new FileNotFoundException("[Script Error] Could not locate the current folder of MCC for scripting.");
|
||||
}
|
||||
|
|
@ -141,7 +141,8 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
|
|||
assemblyrefs.Add(new("Microsoft.Win32.Primitives"));
|
||||
assemblyrefs.Add(new("System.Collections.Concurrent"));
|
||||
|
||||
foreach (var refs in assemblyrefs) {
|
||||
foreach (var refs in assemblyrefs)
|
||||
{
|
||||
Assembly? loadedAssembly;
|
||||
try
|
||||
{
|
||||
|
|
@ -153,19 +154,22 @@ namespace MinecraftClient.Scripting.DynamicRun.Builder
|
|||
continue;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(loadedAssembly.Location)) {
|
||||
if (string.IsNullOrEmpty(loadedAssembly.Location))
|
||||
{
|
||||
// Check if we can access the file from the executable.
|
||||
var reference = files.FirstOrDefault(x =>
|
||||
Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name);
|
||||
var refCount = files.Count(x => Path.GetFileNameWithoutExtension(x.RelativePath) == refs.Name);
|
||||
if (refCount > 1) {
|
||||
if (refCount > 1)
|
||||
{
|
||||
// Safety net for the case where the assembly is referenced multiple times.
|
||||
// Should not happen normally, but we can make exceptions when it does happen.
|
||||
throw new InvalidOperationException(
|
||||
"[Script Error] Too many references to the same assembly. Assembly name: " + refs.Name);
|
||||
}
|
||||
|
||||
if (reference is null) {
|
||||
if (reference is null)
|
||||
{
|
||||
// Facade assemblies may not be in the bundle - skip them silently
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue