From 8c31c04c3e0af1eaf9e1fda95b988e4668e16c8b Mon Sep 17 00:00:00 2001 From: ReinforceZwei <39955851+ReinforceZwei@users.noreply.github.com> Date: Sun, 22 Mar 2020 16:04:22 +0800 Subject: [PATCH] Tidy up code Move variable declaration to the top Delete unnecessary kill.cs file --- MinecraftClient/ChatBots/kill.cs | 15 ------- MinecraftClient/McTcpClient.cs | 76 ++++++++++++++++++-------------- 2 files changed, 44 insertions(+), 47 deletions(-) delete mode 100644 MinecraftClient/ChatBots/kill.cs diff --git a/MinecraftClient/ChatBots/kill.cs b/MinecraftClient/ChatBots/kill.cs deleted file mode 100644 index ece0fefe..00000000 --- a/MinecraftClient/ChatBots/kill.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace MinecraftClient.ChatBots -{ - class kill : ChatBot - { - public override void Update() - { - - } - } -} diff --git a/MinecraftClient/McTcpClient.cs b/MinecraftClient/McTcpClient.cs index 838ab873..7ac1464b 100644 --- a/MinecraftClient/McTcpClient.cs +++ b/MinecraftClient/McTcpClient.cs @@ -55,6 +55,47 @@ namespace MinecraftClient private DateTime lastKeepAlive; private object lastKeepAliveLock = new object(); + private int playerEntityID; + + // auto attack + private class Entity + { + public int ID; + public int Type; + public string Name; + public Location Location; + public Entity(int ID, Location location) + { + this.ID = ID; + this.Location = location; + } + public Entity(int ID, int Type, string Name, Location location) + { + this.ID = ID; + this.Type = Type; + this.Name = Name; + this.Location = location; + } + } + private Dictionary entitiesToAttack = new Dictionary(); // mobs within attack range + private Dictionary entitiesToTrack = new Dictionary(); // all mobs in view distance + private int attackCooldown = 6; + private int attackCooldownCounter = 6; + private Double attackSpeed; + private Double attackCooldownSecond; + private int attackRange = 4; + + // server TPS + private long lastAge = 0; + private DateTime lastTime; + private Double serverTPS = 0; + + public bool AutoAttack + { + get => Settings.AutoAttackMobs; + set => Settings.AutoAttackMobs = value; + } + public int GetServerPort() { return port; } public string GetServerHost() { return host; } public string GetUsername() { return username; } @@ -819,7 +860,6 @@ namespace MinecraftClient } // auto attack entity within range - // by reinforce if (Settings.AutoAttackMobs) { if (attackCooldownCounter == 0) @@ -1041,33 +1081,7 @@ namespace MinecraftClient } } - // by reinforce - public class Entity - { - public int ID; - public int Type; - public string Name; - public Location Location; - public Entity(int ID,Location location) - { - this.ID = ID; - this.Location = location; - } - public Entity(int ID,int Type,string Name,Location location) - { - this.ID = ID; - this.Type = Type; - this.Name = Name; - this.Location = location; - } - } - public Dictionary entitiesToAttack = new Dictionary(); // mobs within attack range - public Dictionary entitiesToTrack = new Dictionary(); // all mobs in view distance - public int attackCooldown = 6; - public int attackCooldownCounter = 6; - public Double attackSpeed; - public Double attackCooldownSecond; - public int attackRange = 4; + /// /// Called when an Entity was created/spawned. @@ -1171,9 +1185,7 @@ namespace MinecraftClient } } - long lastAge = 0; - DateTime lastTime; - Double serverTPS = 0; + /// /// Called when server sent a Time Update packet. /// @@ -1265,7 +1277,7 @@ namespace MinecraftClient default: return ""; } } - public int playerEntityID; + /// /// Set client player's ID for later receiving player's own properties ///