MC 1.17/1.18 Terrain/Entity/Inventory (#1943)

Merge branch 'master' of github.com:milutinke/Minecraft-Console-Client into milutinke-master

Manually fix merge conflicts
Additional changes:
 - WindowItems: Fix data type for "elements" below 1.17
 - DestroyEntities: Fix packet palettes and remove DestroyEntity
 - EntityMetadata: Throw exception if health field mapping is not updated

Co-authored-by: Milutinke <bgteam@live.com>
Co-authored-by: BruceChen <MrChen131217@gmail.com>
This commit is contained in:
ORelio 2022-08-19 16:35:55 +02:00
commit 1ce7850193
34 changed files with 5983 additions and 920 deletions

View file

@ -103,11 +103,15 @@ namespace MinecraftClient.ChatBots
}
}
}
// check entity distance and health again
if (shouldAttackEntity(entitiesToAttack[priorityEntity]))
if (entitiesToAttack.ContainsKey(priorityEntity))
{
InteractEntity(priorityEntity, interactMode); // hit the entity!
SendAnimation(Inventory.Hand.MainHand); // Arm animation
// check entity distance and health again
if (shouldAttackEntity(entitiesToAttack[priorityEntity]))
{
InteractEntity(priorityEntity, interactMode); // hit the entity!
SendAnimation(Inventory.Hand.MainHand); // Arm animation
}
}
}
else
@ -143,6 +147,22 @@ namespace MinecraftClient.ChatBots
}
}
public override void OnEntityHealth(Entity entity, float health)
{
if (!entity.Type.IsHostile())
return;
if (entitiesToAttack.ContainsKey(entity.ID))
{
entitiesToAttack[entity.ID].Health = health;
if (entitiesToAttack[entity.ID].Health <= 0)
{
entitiesToAttack.Remove(entity.ID);
}
}
}
public override void OnEntityMove(Entity entity)
{
shouldAttackEntity(entity);