mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-11-07 17:36:07 +00:00
Add Entity.Item, Entity.CustomName, OnEntityMetadata event (#1222)
* Add New Event * new Event * Add OnEntityMetadaTa * Update ChatBot.cs * Update Protocol18.cs * Update Entity.cs * EntityCMD Update * Update IMinecraftComHandler.cs * Update Protocol18.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update ChatBot.cs * Update McClient.cs * Update Entity.cs * Create EntityPose.cs * Update MinecraftClient.csproj * Update McClient.cs * Update EntityPose.cs * Update Entity.cs * Update McClient.cs * Remove debug line * Update Entitycmd.cs * Update Entity.cs * Update McClient.cs * Update Entity.cs * Update McClient.cs * Update McClient.cs * Update Entity.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entity.cs * Update McClient.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Update Entitycmd.cs * Crash Fix on Item * Crashes Fix * Update McClient.cs * Crashes fix * Update McClient.cs * Update Entity.cs * Update Entity.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update McClient.cs * Update ChatBot.cs * Update IMinecraftComHandler.cs * Update McClient.cs * Update Protocol18.cs * Update ChatBot.cs * Update IMinecraftComHandler.cs * Update Protocol18.cs * Update McClient.cs * Fix unaddressed issues Co-authored-by: ORelio <oreliogitantispam.l0gin@spamgourmet.com>
This commit is contained in:
parent
a6a5f0c333
commit
c2e2e85063
9 changed files with 207 additions and 31 deletions
|
|
@ -3,13 +3,14 @@ using System.Collections.Generic;
|
|||
using System.Linq;
|
||||
using System.Text;
|
||||
using MinecraftClient.Inventory;
|
||||
using MinecraftClient.Mapping;
|
||||
|
||||
namespace MinecraftClient.Commands
|
||||
{
|
||||
class Entitycmd : Command
|
||||
{
|
||||
public override string CMDName { get { return "entity"; } }
|
||||
public override string CMDDesc { get { return "entity <id> <list|attack|use>"; } }
|
||||
public override string CMDDesc { get { return "entity <id|entitytype> <list|attack|use>"; } }
|
||||
|
||||
public override string Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||
{
|
||||
|
|
@ -20,21 +21,55 @@ namespace MinecraftClient.Commands
|
|||
{
|
||||
try
|
||||
{
|
||||
int entityID;
|
||||
entityID = int.Parse(args[0]);
|
||||
string action = args.Length > 1
|
||||
? args[1].ToLower()
|
||||
: "list";
|
||||
switch (action)
|
||||
int entityID = 0;
|
||||
int.TryParse(args[0], out entityID);
|
||||
if (entityID != 0)
|
||||
{
|
||||
case "attack":
|
||||
handler.InteractEntity(entityID, 1);
|
||||
return "Entity attacked";
|
||||
case "use":
|
||||
handler.InteractEntity(entityID, 0);
|
||||
return "Entity used";
|
||||
default:
|
||||
return CMDDesc;
|
||||
string action = args.Length > 1
|
||||
? args[1].ToLower()
|
||||
: "list";
|
||||
switch (action)
|
||||
{
|
||||
case "attack":
|
||||
handler.InteractEntity(entityID, 1);
|
||||
return "Entity attacked";
|
||||
case "use":
|
||||
handler.InteractEntity(entityID, 0);
|
||||
return "Entity used";
|
||||
default:
|
||||
return CMDDesc;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EntityType interacttype = EntityType.Player;
|
||||
Enum.TryParse(args[0], out interacttype);
|
||||
Dictionary<int, Mapping.Entity> entities = handler.GetEntities();
|
||||
string actionst = "Entity attacked";
|
||||
int actioncount = 0;
|
||||
foreach (var entity2 in entities)
|
||||
{
|
||||
if (entity2.Value.Type == interacttype)
|
||||
{
|
||||
string action = args.Length > 1
|
||||
? args[1].ToLower()
|
||||
: "list";
|
||||
if (action == "attack")
|
||||
{
|
||||
handler.InteractEntity(entity2.Key, 1);
|
||||
actionst = "Entity attacked";
|
||||
actioncount++;
|
||||
}
|
||||
else if (action == "use")
|
||||
{
|
||||
handler.InteractEntity(entity2.Key, 0);
|
||||
actionst = "Entity used";
|
||||
actioncount++;
|
||||
}
|
||||
else return CMDDesc;
|
||||
}
|
||||
}
|
||||
return actioncount + " " + actionst;
|
||||
}
|
||||
}
|
||||
catch (FormatException) { return CMDDesc; }
|
||||
|
|
@ -46,10 +81,12 @@ namespace MinecraftClient.Commands
|
|||
response.Add("Entities:");
|
||||
foreach (var entity2 in entities)
|
||||
{
|
||||
if (entity2.Value.Type == Mapping.EntityType.Player)
|
||||
response.Add(String.Format(" #{0}: {1} | {2}", entity2.Key, entity2.Value.Type, entity2.Value.Name));
|
||||
if (entity2.Value.Type == EntityType.Item || entity2.Value.Type == EntityType.ItemFrame || entity2.Value.Type == Mapping.EntityType.EyeOfEnder || entity2.Value.Type == Mapping.EntityType.Egg || entity2.Value.Type == Mapping.EntityType.EnderPearl || entity2.Value.Type == Mapping.EntityType.Potion || entity2.Value.Type == Mapping.EntityType.Fireball || entity2.Value.Type == Mapping.EntityType.FireworkRocket)
|
||||
response.Add(String.Format(" #{0}: Type: {1}, Item: {2}, Location: {3}", entity2.Key, entity2.Value.Type, entity2.Value.Item.Type, entity2.Value.Location));
|
||||
else if (entity2.Value.Type == Mapping.EntityType.Player && entity2.Value.Name != string.Empty)
|
||||
response.Add(String.Format(" #{0}: Type: {1}, Nickname: {2}, Latency: {3}, Health: {4}, Pose: {5}, Location: {6}", entity2.Key, entity2.Value.Type, entity2.Value.Name, entity2.Value.Latency, entity2.Value.Health, entity2.Value.Pose, entity2.Value.Location));
|
||||
else
|
||||
response.Add(String.Format(" #{0}: {1}", entity2.Key, entity2.Value.Type));
|
||||
response.Add(String.Format(" #{0}: Type: {1}, Health: {2}, Location: {3}", entity2.Key, entity2.Value.Type, entity2.Value.Health, entity2.Value.Location));
|
||||
}
|
||||
response.Add(CMDDesc);
|
||||
return String.Join("\n", response);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue