mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2025-10-14 21:22:49 +00:00
Add /entity cmd (#1129)
* Update MinecraftClient.csproj * Create Entitycmd.cs * Update MinecraftClient.csproj * Update Protocol18PacketTypes.cs * Update Protocol18PacketTypes.cs
This commit is contained in:
parent
9370064072
commit
835df9b1fc
3 changed files with 66 additions and 3 deletions
61
MinecraftClient/Commands/Entitycmd.cs
Normal file
61
MinecraftClient/Commands/Entitycmd.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using MinecraftClient.Inventory;
|
||||||
|
|
||||||
|
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 Run(McClient handler, string command, Dictionary<string, object> localVars)
|
||||||
|
{
|
||||||
|
if (handler.GetEntityHandlingEnabled())
|
||||||
|
{
|
||||||
|
string[] args = getArgs(command);
|
||||||
|
if (args.Length >= 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
int entityID;
|
||||||
|
entityID = int.Parse(args[0]);
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (FormatException) { return CMDDesc; }
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Dictionary<int, Mapping.Entity> entities = handler.GetEntities();
|
||||||
|
List<string> response = new List<string>();
|
||||||
|
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));
|
||||||
|
else
|
||||||
|
response.Add(String.Format(" #{0}: {1}", entity2.Key, entity2.Value.Type));
|
||||||
|
}
|
||||||
|
response.Add(CMDDesc);
|
||||||
|
return String.Join("\n", response);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else return "Please enable entityhandling in config to use this command.";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -73,6 +73,8 @@
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AutoTimeout.cs" />
|
<Compile Include="AutoTimeout.cs" />
|
||||||
|
<Compile Include="Commands\Entitycmd.cs" />
|
||||||
|
<Compile Include="Commands\Entitycmd.cs" />
|
||||||
<Compile Include="ChatBots\Alerts.cs" />
|
<Compile Include="ChatBots\Alerts.cs" />
|
||||||
<Compile Include="ChatBots\AntiAFK.cs" />
|
<Compile Include="ChatBots\AntiAFK.cs" />
|
||||||
<Compile Include="ChatBots\AutoAttack.cs" />
|
<Compile Include="ChatBots\AutoAttack.cs" />
|
||||||
|
|
|
||||||
|
|
@ -293,11 +293,11 @@ namespace MinecraftClient.Protocol.Handlers
|
||||||
case 0x58: return PacketIncomingType.EntityProperties;
|
case 0x58: return PacketIncomingType.EntityProperties;
|
||||||
case 0x56: return PacketIncomingType.EntityTeleport;
|
case 0x56: return PacketIncomingType.EntityTeleport;
|
||||||
case 0x41: return PacketIncomingType.EntityVelocity;
|
case 0x41: return PacketIncomingType.EntityVelocity;
|
||||||
case 0x42: return PacketIncomingType.EntityEquipment;
|
case 0x46: return PacketIncomingType.EntityEquipment;
|
||||||
case 0x59: return PacketIncomingType.EntityEffect;
|
case 0x59: return PacketIncomingType.EntityEffect;
|
||||||
case 0x4E: return PacketIncomingType.TimeUpdate;
|
case 0x4E: return PacketIncomingType.TimeUpdate;
|
||||||
case 0x48: return PacketIncomingType.UpdateHealth;
|
case 0x48: return PacketIncomingType.UpdateHealth;
|
||||||
case 0x45: return PacketIncomingType.SetExperience;
|
case 0x47: return PacketIncomingType.SetExperience;
|
||||||
case 0x3F: return PacketIncomingType.HeldItemChange;
|
case 0x3F: return PacketIncomingType.HeldItemChange;
|
||||||
case 0x1C: return PacketIncomingType.Explosion;
|
case 0x1C: return PacketIncomingType.Explosion;
|
||||||
case 0x26: return PacketIncomingType.MapData;
|
case 0x26: return PacketIncomingType.MapData;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue