From ccc364df347ff26422fd5fc89822bc02403b2b4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=94=D0=B0=D0=BD=D0=B8=D0=BB?=
=?UTF-8?q?=D0=BE=D0=B2?= <35975332+Nekiplay@users.noreply.github.com>
Date: Fri, 7 Aug 2020 13:35:23 +0500
Subject: [PATCH] Add OnTimeUpdate() and OnRespawn() to ChatBot API
---
MinecraftClient/ChatBot.cs | 12 ++++++++++++
MinecraftClient/McClient.cs | 2 ++
2 files changed, 14 insertions(+)
diff --git a/MinecraftClient/ChatBot.cs b/MinecraftClient/ChatBot.cs
index d4cdf4da..1e7b59b4 100644
--- a/MinecraftClient/ChatBot.cs
+++ b/MinecraftClient/ChatBot.cs
@@ -153,6 +153,13 @@ namespace MinecraftClient
/// New estimated server TPS (between 0 and 20)
public virtual void OnServerTpsUpdate(Double tps) { }
+ ///
+ /// Called when a time changed
+ ///
+ /// World age
+ /// Time
+ public virtual void OnTimeUpdate(long WorldAge, long TimeOfDay) { }
+
///
/// Called when an entity moved nearby
///
@@ -312,6 +319,11 @@ namespace MinecraftClient
/// UUID of the player
/// Name of the player
public virtual void OnPlayerLeave(Guid uuid, string name) { }
+
+ ///
+ /// Called when the player respawns
+ ///
+ public virtual void OnRespawn() { }
/* =================================================================== */
/* ToolBox - Methods below might be useful while creating your bot. */
diff --git a/MinecraftClient/McClient.cs b/MinecraftClient/McClient.cs
index 6ffe2c41..ba2b95dd 100644
--- a/MinecraftClient/McClient.cs
+++ b/MinecraftClient/McClient.cs
@@ -1522,6 +1522,7 @@ namespace MinecraftClient
}
ClearInventories();
+ DispatchBotEvent(bot => bot.OnRespawn());
}
///
@@ -1978,6 +1979,7 @@ namespace MinecraftClient
lastAge = WorldAge;
lastTime = DateTime.Now;
}
+ DispatchBotEvent(bot => bot.OnTimeUpdate(WorldAge, TimeOfDay));
}
///