mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
parent
c2dc483d36
commit
9dae40153c
3 changed files with 82 additions and 0 deletions
|
|
@ -168,8 +168,17 @@ namespace MinecraftClient
|
||||||
/// <param name="entity">Entity wich has just disappeared</param>
|
/// <param name="entity">Entity wich has just disappeared</param>
|
||||||
public virtual void OnEntityDespawn(Mapping.Entity entity) { }
|
public virtual void OnEntityDespawn(Mapping.Entity entity) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the player held item has changed
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="slot">New slot ID</param>
|
||||||
public virtual void OnHeldItemChange(byte slot) { }
|
public virtual void OnHeldItemChange(byte slot) { }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Called when the player health has been updated
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="health">New player health</param>
|
||||||
|
/// <param name="food">New food level</param>
|
||||||
public virtual void OnHealthUpdate(float health, int food) { }
|
public virtual void OnHealthUpdate(float health, int food) { }
|
||||||
|
|
||||||
/* =================================================================== */
|
/* =================================================================== */
|
||||||
|
|
@ -685,6 +694,15 @@ namespace MinecraftClient
|
||||||
return Handler.MoveTo(location, allowUnsafe);
|
return Handler.MoveTo(location, allowUnsafe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Look at the specified location
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="location">Location to look at</param>
|
||||||
|
protected void LookAtLocation(Mapping.Location location)
|
||||||
|
{
|
||||||
|
Handler.UpdateLocation(Handler.GetCurrentLocation(), location);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get a Y-M-D h:m:s timestamp representing the current system date and time
|
/// Get a Y-M-D h:m:s timestamp representing the current system date and time
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
64
MinecraftClient/config/ChatBots/AutoLook.cs
Normal file
64
MinecraftClient/config/ChatBots/AutoLook.cs
Normal file
|
|
@ -0,0 +1,64 @@
|
||||||
|
//MCCScript 1.0
|
||||||
|
|
||||||
|
MCC.LoadBot(new AutoLook());
|
||||||
|
|
||||||
|
//MCCScript Extensions
|
||||||
|
|
||||||
|
public class AutoLook : ChatBot
|
||||||
|
{
|
||||||
|
private Entity _entityToLookAt;
|
||||||
|
public override void Initialize()
|
||||||
|
{
|
||||||
|
if (GetEntityHandlingEnabled() && GetTerrainEnabled()) return;
|
||||||
|
LogToConsole("Entity Handling or Terrain Handling is not enabled in the config file!");
|
||||||
|
LogToConsole("This bot will be unloaded.");
|
||||||
|
UnloadBot();
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void OnEntityDespawn(Entity entity)
|
||||||
|
{
|
||||||
|
if (entity == _entityToLookAt)
|
||||||
|
{
|
||||||
|
_entityToLookAt = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public override void OnEntitySpawn(Entity entity)
|
||||||
|
{
|
||||||
|
HandleEntity(entity);
|
||||||
|
}
|
||||||
|
public override void OnEntityMove(Entity entity)
|
||||||
|
{
|
||||||
|
var tempBool = HandleEntity(entity);
|
||||||
|
//LogDebugToConsole(tempBool);
|
||||||
|
if (!tempBool) return;
|
||||||
|
LookAtLocation(entity.Location);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handles an entity, and tracks it if it is closer then the one we are currently tracking
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>True if found</returns>
|
||||||
|
private bool HandleEntity(Entity entity)
|
||||||
|
{
|
||||||
|
if (entity.Type != EntityType.Player)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_entityToLookAt == null)
|
||||||
|
{
|
||||||
|
_entityToLookAt = entity;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (GetCurrentLocation().Distance(entity.Location) < GetCurrentLocation().Distance(_entityToLookAt.Location))
|
||||||
|
{
|
||||||
|
_entityToLookAt = entity;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entity.ID != _entityToLookAt.ID) return false;
|
||||||
|
_entityToLookAt = entity; //Handle looking at the same entity
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue