Skip to content

Commit

Permalink
Partially fixed interaction with Armor Stand
Browse files Browse the repository at this point in the history
Partially fixed interaction with Armor Stand
  • Loading branch information
milutinke authored Mar 31, 2023
2 parents bbb3b1e + db6422d commit f215921
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
6 changes: 5 additions & 1 deletion MinecraftClient/Commands/Entitycmd.cs
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,11 @@ private static string InteractionWithEntity(McClient handler, Entity entity, Act
handler.InteractEntity(entity.ID, InteractType.Attack);
return Translations.cmd_entityCmd_attacked;
case ActionType.Use:
handler.InteractEntity(entity.ID, InteractType.Interact);
bool shouldInteractAt = entity.Type == EntityType.ArmorStand ||
entity.Type == EntityType.ChestMinecart ||
entity.Type == EntityType.ChestBoat;

handler.InteractEntity(entity.ID, shouldInteractAt ? InteractType.InteractAt : InteractType.Interact);
return Translations.cmd_entityCmd_used;
case ActionType.List:
return GetEntityInfoDetailed(handler, entity);
Expand Down
24 changes: 17 additions & 7 deletions MinecraftClient/McClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2195,16 +2195,26 @@ public bool InteractEntity(int entityID, InteractType type, Hand hand = Hand.Mai

if (entities.ContainsKey(entityID))
{
if (type == InteractType.Interact)
switch (type)
{
return handler.SendInteractEntity(entityID, (int)type, (int)hand);
}
else
{
return handler.SendInteractEntity(entityID, (int)type);
case InteractType.Interact:
return handler.SendInteractEntity(entityID, (int)type, (int)hand);

case InteractType.InteractAt:
return handler.SendInteractEntity(
EntityID: entityID,
type: (int)type,
X: (float)entities[entityID].Location.X,
Y: (float)entities[entityID].Location.Y,
Z: (float)entities[entityID].Location.Z,
hand: (int)hand);

default:
return handler.SendInteractEntity(entityID, (int)type);
}
}
else return false;

return false;
}

/// <summary>
Expand Down

0 comments on commit f215921

Please sign in to comment.