Initial commit

This commit is contained in:
Astatin3
2024-04-30 22:07:50 -06:00
commit 8565caa62a
8463 changed files with 4915934 additions and 0 deletions
+697
View File
@@ -0,0 +1,697 @@
project(botcraft)
set(botcraft_PUBLIC_HDR
include/botcraft/AI/BaseNode.hpp
include/botcraft/AI/BehaviourClient.hpp
include/botcraft/AI/BehaviourTree.hpp
include/botcraft/AI/Blackboard.hpp
include/botcraft/AI/SimpleBehaviourClient.hpp
include/botcraft/AI/Status.hpp
include/botcraft/AI/TemplatedBehaviourClient.hpp
include/botcraft/AI/Tasks/AllTasks.hpp
include/botcraft/AI/Tasks/BaseTasks.hpp
include/botcraft/AI/Tasks/DigTask.hpp
include/botcraft/AI/Tasks/EntitiesTasks.hpp
include/botcraft/AI/Tasks/InventoryTasks.hpp
include/botcraft/AI/Tasks/PathfindingTask.hpp
include/botcraft/Game/AssetsManager.hpp
include/botcraft/Game/ManagersClient.hpp
include/botcraft/Game/ConnectionClient.hpp
include/botcraft/Game/Enums.hpp
include/botcraft/Game/Model.hpp
include/botcraft/Game/Vector3.hpp
include/botcraft/Game/World/Biome.hpp
include/botcraft/Game/World/Blockstate.hpp
include/botcraft/Game/World/Chunk.hpp
include/botcraft/Game/World/World.hpp
include/botcraft/Game/Entities/EntityAttribute.hpp
include/botcraft/Game/Entities/EntityManager.hpp
include/botcraft/Game/Entities/GlobalPos.hpp
include/botcraft/Game/Entities/LocalPlayer.hpp
include/botcraft/Game/Entities/VillagerData.hpp
include/botcraft/Game/Entities/entities/UnknownEntity.hpp
include/botcraft/Game/Entities/entities/animal/allay/AllayEntity.hpp
include/botcraft/Game/Entities/entities/AreaEffectCloudEntity.hpp
include/botcraft/Game/Entities/entities/decoration/ArmorStandEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ArrowEntity.hpp
include/botcraft/Game/Entities/entities/animal/axolotl/AxolotlEntity.hpp
include/botcraft/Game/Entities/entities/ambient/BatEntity.hpp
include/botcraft/Game/Entities/entities/animal/BeeEntity.hpp
include/botcraft/Game/Entities/entities/monster/BlazeEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/BoatEntity.hpp
include/botcraft/Game/Entities/entities/monster/breeze/BreezeEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/ChestBoatEntity.hpp
include/botcraft/Game/Entities/entities/animal/CatEntity.hpp
include/botcraft/Game/Entities/entities/animal/camel/CamelEntity.hpp
include/botcraft/Game/Entities/entities/monster/CaveSpiderEntity.hpp
include/botcraft/Game/Entities/entities/animal/ChickenEntity.hpp
include/botcraft/Game/Entities/entities/animal/CodEntity.hpp
include/botcraft/Game/Entities/entities/animal/CowEntity.hpp
include/botcraft/Game/Entities/entities/monster/CreeperEntity.hpp
include/botcraft/Game/Entities/entities/animal/DolphinEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/DonkeyEntity.hpp
include/botcraft/Game/Entities/entities/projectile/DragonFireballEntity.hpp
include/botcraft/Game/Entities/entities/DisplayBlockDisplayEntity.hpp
include/botcraft/Game/Entities/entities/DisplayEntity.hpp
include/botcraft/Game/Entities/entities/DisplayItemDisplayEntity.hpp
include/botcraft/Game/Entities/entities/DisplayTextDisplayEntity.hpp
include/botcraft/Game/Entities/entities/monster/DrownedEntity.hpp
include/botcraft/Game/Entities/entities/monster/ElderGuardianEntity.hpp
include/botcraft/Game/Entities/entities/boss/enderdragon/EndCrystalEntity.hpp
include/botcraft/Game/Entities/entities/boss/enderdragon/EnderDragonEntity.hpp
include/botcraft/Game/Entities/entities/monster/EnderManEntity.hpp
include/botcraft/Game/Entities/entities/monster/EndermiteEntity.hpp
include/botcraft/Game/Entities/entities/monster/EvokerEntity.hpp
include/botcraft/Game/Entities/entities/projectile/EvokerFangsEntity.hpp
include/botcraft/Game/Entities/entities/ExperienceOrbEntity.hpp
include/botcraft/Game/Entities/entities/projectile/EyeOfEnderEntity.hpp
include/botcraft/Game/Entities/entities/item/FallingBlockEntity.hpp
include/botcraft/Game/Entities/entities/projectile/FireworkRocketEntity.hpp
include/botcraft/Game/Entities/entities/animal/FoxEntity.hpp
include/botcraft/Game/Entities/entities/animal/frog/FrogEntity.hpp
include/botcraft/Game/Entities/entities/monster/GhastEntity.hpp
include/botcraft/Game/Entities/entities/monster/GiantEntity.hpp
include/botcraft/Game/Entities/entities/decoration/GlowItemFrameEntity.hpp
include/botcraft/Game/Entities/entities/GlowSquidEntity.hpp
include/botcraft/Game/Entities/entities/animal/goat/GoatEntity.hpp
include/botcraft/Game/Entities/entities/monster/GuardianEntity.hpp
include/botcraft/Game/Entities/entities/monster/hoglin/HoglinEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/HorseEntity.hpp
include/botcraft/Game/Entities/entities/monster/HuskEntity.hpp
include/botcraft/Game/Entities/entities/monster/IllusionerEntity.hpp
include/botcraft/Game/Entities/entities/InteractionEntity.hpp
include/botcraft/Game/Entities/entities/animal/IronGolemEntity.hpp
include/botcraft/Game/Entities/entities/item/ItemEntity.hpp
include/botcraft/Game/Entities/entities/decoration/ItemFrameEntity.hpp
include/botcraft/Game/Entities/entities/projectile/LargeFireballEntity.hpp
include/botcraft/Game/Entities/entities/decoration/LeashFenceKnotEntity.hpp
include/botcraft/Game/Entities/entities/LightningBoltEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/LlamaEntity.hpp
include/botcraft/Game/Entities/entities/projectile/LlamaSpitEntity.hpp
include/botcraft/Game/Entities/entities/monster/MagmaCubeEntity.hpp
include/botcraft/Game/Entities/entities/MarkerEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartChestEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartCommandBlockEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartFurnaceEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartHopperEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartSpawnerEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/MinecartTNTEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/MuleEntity.hpp
include/botcraft/Game/Entities/entities/animal/MushroomCowEntity.hpp
include/botcraft/Game/Entities/entities/animal/OcelotEntity.hpp
include/botcraft/Game/Entities/entities/decoration/PaintingEntity.hpp
include/botcraft/Game/Entities/entities/animal/PandaEntity.hpp
include/botcraft/Game/Entities/entities/animal/ParrotEntity.hpp
include/botcraft/Game/Entities/entities/monster/PhantomEntity.hpp
include/botcraft/Game/Entities/entities/monster/PigZombieEntity.hpp
include/botcraft/Game/Entities/entities/animal/PigEntity.hpp
include/botcraft/Game/Entities/entities/monster/piglin/PiglinEntity.hpp
include/botcraft/Game/Entities/entities/monster/piglin/PiglinBruteEntity.hpp
include/botcraft/Game/Entities/entities/monster/PillagerEntity.hpp
include/botcraft/Game/Entities/entities/animal/PolarBearEntity.hpp
include/botcraft/Game/Entities/entities/item/PrimedTntEntity.hpp
include/botcraft/Game/Entities/entities/animal/PufferfishEntity.hpp
include/botcraft/Game/Entities/entities/animal/RabbitEntity.hpp
include/botcraft/Game/Entities/entities/monster/RavagerEntity.hpp
include/botcraft/Game/Entities/entities/animal/SalmonEntity.hpp
include/botcraft/Game/Entities/entities/animal/SheepEntity.hpp
include/botcraft/Game/Entities/entities/monster/ShulkerEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ShulkerBulletEntity.hpp
include/botcraft/Game/Entities/entities/monster/SilverfishEntity.hpp
include/botcraft/Game/Entities/entities/monster/SkeletonEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/SkeletonHorseEntity.hpp
include/botcraft/Game/Entities/entities/monster/SlimeEntity.hpp
include/botcraft/Game/Entities/entities/projectile/SmallFireballEntity.hpp
include/botcraft/Game/Entities/entities/animal/sniffer/SnifferEntity.hpp
include/botcraft/Game/Entities/entities/animal/SnowGolemEntity.hpp
include/botcraft/Game/Entities/entities/projectile/SnowballEntity.hpp
include/botcraft/Game/Entities/entities/projectile/SpectralArrowEntity.hpp
include/botcraft/Game/Entities/entities/monster/SpiderEntity.hpp
include/botcraft/Game/Entities/entities/animal/SquidEntity.hpp
include/botcraft/Game/Entities/entities/monster/StrayEntity.hpp
include/botcraft/Game/Entities/entities/monster/StriderEntity.hpp
include/botcraft/Game/Entities/entities/animal/frog/TadpoleEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrownEggEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrownEnderpearlEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrownExperienceBottleEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrownPotionEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrownTridentEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/TraderLlamaEntity.hpp
include/botcraft/Game/Entities/entities/animal/TropicalFishEntity.hpp
include/botcraft/Game/Entities/entities/animal/TurtleEntity.hpp
include/botcraft/Game/Entities/entities/monster/VexEntity.hpp
include/botcraft/Game/Entities/entities/npc/VillagerEntity.hpp
include/botcraft/Game/Entities/entities/monster/VindicatorEntity.hpp
include/botcraft/Game/Entities/entities/npc/WanderingTraderEntity.hpp
include/botcraft/Game/Entities/entities/monster/warden/WardenEntity.hpp
include/botcraft/Game/Entities/entities/projectile/WindChargeEntity.hpp
include/botcraft/Game/Entities/entities/monster/WitchEntity.hpp
include/botcraft/Game/Entities/entities/boss/wither/WitherBossEntity.hpp
include/botcraft/Game/Entities/entities/monster/WitherSkeletonEntity.hpp
include/botcraft/Game/Entities/entities/projectile/WitherSkullEntity.hpp
include/botcraft/Game/Entities/entities/animal/WolfEntity.hpp
include/botcraft/Game/Entities/entities/monster/ZoglinEntity.hpp
include/botcraft/Game/Entities/entities/monster/ZombieEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/ZombieHorseEntity.hpp
include/botcraft/Game/Entities/entities/monster/ZombieVillagerEntity.hpp
include/botcraft/Game/Entities/entities/monster/ZombifiedPiglinEntity.hpp
include/botcraft/Game/Entities/entities/player/PlayerEntity.hpp
include/botcraft/Game/Entities/entities/projectile/FishingHookEntity.hpp
include/botcraft/Game/Entities/entities/Entity.hpp
include/botcraft/Game/Entities/entities/LivingEntity.hpp
include/botcraft/Game/Entities/entities/projectile/AbstractArrowEntity.hpp
include/botcraft/Game/Entities/entities/animal/AnimalEntity.hpp
include/botcraft/Game/Entities/entities/ambient/AmbientCreatureEntity.hpp
include/botcraft/Game/Entities/entities/monster/MonsterEntity.hpp
include/botcraft/Game/Entities/entities/TamableAnimalEntity.hpp
include/botcraft/Game/Entities/entities/animal/AbstractSchoolingFishEntity.hpp
include/botcraft/Game/Entities/entities/animal/WaterAnimalEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/AbstractChestedHorseEntity.hpp
include/botcraft/Game/Entities/entities/projectile/AbstractHurtingProjectileEntity.hpp
include/botcraft/Game/Entities/entities/MobEntity.hpp
include/botcraft/Game/Entities/entities/monster/SpellcasterIllagerEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ProjectileEntity.hpp
include/botcraft/Game/Entities/entities/FlyingMobEntity.hpp
include/botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp
include/botcraft/Game/Entities/entities/animal/AbstractGolemEntity.hpp
include/botcraft/Game/Entities/entities/decoration/HangingEntity.hpp
include/botcraft/Game/Entities/entities/projectile/FireballEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/VehicleEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/AbstractMinecartEntity.hpp
include/botcraft/Game/Entities/entities/vehicle/AbstractMinecartContainerEntity.hpp
include/botcraft/Game/Entities/entities/animal/ShoulderRidingEntity.hpp
include/botcraft/Game/Entities/entities/monster/piglin/AbstractPiglinEntity.hpp
include/botcraft/Game/Entities/entities/monster/AbstractIllagerEntity.hpp
include/botcraft/Game/Entities/entities/animal/AbstractFishEntity.hpp
include/botcraft/Game/Entities/entities/raid/RaiderEntity.hpp
include/botcraft/Game/Entities/entities/monster/AbstractSkeletonEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrowableItemProjectileEntity.hpp
include/botcraft/Game/Entities/entities/npc/AbstractVillagerEntity.hpp
include/botcraft/Game/Entities/entities/AgeableMobEntity.hpp
include/botcraft/Game/Entities/entities/PathfinderMobEntity.hpp
include/botcraft/Game/Entities/entities/monster/PatrollingMonsterEntity.hpp
include/botcraft/Game/Entities/entities/projectile/ThrowableProjectileEntity.hpp
include/botcraft/Game/Inventory/Window.hpp
include/botcraft/Game/Inventory/InventoryManager.hpp
include/botcraft/Game/Inventory/Item.hpp
include/botcraft/Game/Physics/AABB.hpp
include/botcraft/Game/Physics/PhysicsManager.hpp
include/botcraft/Network/NetworkManager.hpp
include/botcraft/Network/LastSeenMessagesTracker.hpp
include/botcraft/Utilities/DemanglingUtilities.hpp
include/botcraft/Utilities/EnumUtilities.hpp
include/botcraft/Utilities/Logger.hpp
include/botcraft/Utilities/MiscUtilities.hpp
include/botcraft/Utilities/NBTUtilities.hpp
include/botcraft/Utilities/ScopeLockedWrapper.hpp
include/botcraft/Utilities/SleepUtilities.hpp
include/botcraft/Utilities/StdAnyUtilities.hpp
include/botcraft/Utilities/Templates.hpp
)
set(botcraft_PRIVATE_HDR
private_include/botcraft/Network/Authentifier.hpp
private_include/botcraft/Network/AESEncrypter.hpp
private_include/botcraft/Network/Compression.hpp
private_include/botcraft/Network/TCP_Com.hpp
private_include/botcraft/Network/DNS/DNSMessage.hpp
private_include/botcraft/Network/DNS/DNSQuestion.hpp
private_include/botcraft/Network/DNS/DNSResourceRecord.hpp
private_include/botcraft/Network/DNS/DNSSrvData.hpp
private_include/botcraft/Utilities/StringUtilities.hpp
private_include/botcraft/Game/World/Section.hpp
)
set(botcraft_SRC
src/AI/BaseNode.cpp
src/AI/BehaviourClient.cpp
src/AI/Blackboard.cpp
src/AI/SimpleBehaviourClient.cpp
src/AI/Tasks/BaseTasks.cpp
src/AI/Tasks/DigTask.cpp
src/AI/Tasks/EntitiesTasks.cpp
src/AI/Tasks/InventoryTasks.cpp
src/AI/Tasks/PathfindingTask.cpp
src/Game/AssetsManager.cpp
src/Game/ConnectionClient.cpp
src/Game/Enums.cpp
src/Game/ManagersClient.cpp
src/Game/Model.cpp
src/Game/World/Biome.cpp
src/Game/World/Blockstate.cpp
src/Game/World/Chunk.cpp
src/Game/World/Section.cpp
src/Game/World/World.cpp
src/Game/Inventory/Window.cpp
src/Game/Inventory/InventoryManager.cpp
src/Game/Inventory/Item.cpp
src/Game/Entities/EntityAttribute.cpp
src/Game/Entities/EntityManager.cpp
src/Game/Entities/LocalPlayer.cpp
src/Game/Entities/entities/UnknownEntity.cpp
src/Game/Entities/entities/animal/allay/AllayEntity.cpp
src/Game/Entities/entities/AreaEffectCloudEntity.cpp
src/Game/Entities/entities/decoration/ArmorStandEntity.cpp
src/Game/Entities/entities/projectile/ArrowEntity.cpp
src/Game/Entities/entities/animal/axolotl/AxolotlEntity.cpp
src/Game/Entities/entities/ambient/BatEntity.cpp
src/Game/Entities/entities/animal/BeeEntity.cpp
src/Game/Entities/entities/monster/BlazeEntity.cpp
src/Game/Entities/entities/vehicle/BoatEntity.cpp
src/Game/Entities/entities/monster/breeze/BreezeEntity.cpp
src/Game/Entities/entities/vehicle/ChestBoatEntity.cpp
src/Game/Entities/entities/animal/CatEntity.cpp
src/Game/Entities/entities/animal/camel/CamelEntity.cpp
src/Game/Entities/entities/monster/CaveSpiderEntity.cpp
src/Game/Entities/entities/animal/ChickenEntity.cpp
src/Game/Entities/entities/animal/CodEntity.cpp
src/Game/Entities/entities/animal/CowEntity.cpp
src/Game/Entities/entities/monster/CreeperEntity.cpp
src/Game/Entities/entities/animal/DolphinEntity.cpp
src/Game/Entities/entities/animal/horse/DonkeyEntity.cpp
src/Game/Entities/entities/projectile/DragonFireballEntity.cpp
src/Game/Entities/entities/DisplayBlockDisplayEntity.cpp
src/Game/Entities/entities/DisplayEntity.cpp
src/Game/Entities/entities/DisplayItemDisplayEntity.cpp
src/Game/Entities/entities/DisplayTextDisplayEntity.cpp
src/Game/Entities/entities/monster/DrownedEntity.cpp
src/Game/Entities/entities/monster/ElderGuardianEntity.cpp
src/Game/Entities/entities/boss/enderdragon/EndCrystalEntity.cpp
src/Game/Entities/entities/boss/enderdragon/EnderDragonEntity.cpp
src/Game/Entities/entities/monster/EnderManEntity.cpp
src/Game/Entities/entities/monster/EndermiteEntity.cpp
src/Game/Entities/entities/monster/EvokerEntity.cpp
src/Game/Entities/entities/projectile/EvokerFangsEntity.cpp
src/Game/Entities/entities/ExperienceOrbEntity.cpp
src/Game/Entities/entities/projectile/EyeOfEnderEntity.cpp
src/Game/Entities/entities/item/FallingBlockEntity.cpp
src/Game/Entities/entities/projectile/FireworkRocketEntity.cpp
src/Game/Entities/entities/animal/FoxEntity.cpp
src/Game/Entities/entities/animal/frog/FrogEntity.cpp
src/Game/Entities/entities/monster/GhastEntity.cpp
src/Game/Entities/entities/monster/GiantEntity.cpp
src/Game/Entities/entities/decoration/GlowItemFrameEntity.cpp
src/Game/Entities/entities/GlowSquidEntity.cpp
src/Game/Entities/entities/animal/goat/GoatEntity.cpp
src/Game/Entities/entities/monster/GuardianEntity.cpp
src/Game/Entities/entities/monster/hoglin/HoglinEntity.cpp
src/Game/Entities/entities/animal/horse/HorseEntity.cpp
src/Game/Entities/entities/monster/HuskEntity.cpp
src/Game/Entities/entities/monster/IllusionerEntity.cpp
src/Game/Entities/entities/InteractionEntity.cpp
src/Game/Entities/entities/animal/IronGolemEntity.cpp
src/Game/Entities/entities/item/ItemEntity.cpp
src/Game/Entities/entities/decoration/ItemFrameEntity.cpp
src/Game/Entities/entities/projectile/LargeFireballEntity.cpp
src/Game/Entities/entities/decoration/LeashFenceKnotEntity.cpp
src/Game/Entities/entities/LightningBoltEntity.cpp
src/Game/Entities/entities/animal/horse/LlamaEntity.cpp
src/Game/Entities/entities/projectile/LlamaSpitEntity.cpp
src/Game/Entities/entities/monster/MagmaCubeEntity.cpp
src/Game/Entities/entities/MarkerEntity.cpp
src/Game/Entities/entities/vehicle/MinecartEntity.cpp
src/Game/Entities/entities/vehicle/MinecartChestEntity.cpp
src/Game/Entities/entities/vehicle/MinecartCommandBlockEntity.cpp
src/Game/Entities/entities/vehicle/MinecartFurnaceEntity.cpp
src/Game/Entities/entities/vehicle/MinecartHopperEntity.cpp
src/Game/Entities/entities/vehicle/MinecartSpawnerEntity.cpp
src/Game/Entities/entities/vehicle/MinecartTNTEntity.cpp
src/Game/Entities/entities/animal/horse/MuleEntity.cpp
src/Game/Entities/entities/animal/MushroomCowEntity.cpp
src/Game/Entities/entities/animal/OcelotEntity.cpp
src/Game/Entities/entities/decoration/PaintingEntity.cpp
src/Game/Entities/entities/animal/PandaEntity.cpp
src/Game/Entities/entities/animal/ParrotEntity.cpp
src/Game/Entities/entities/monster/PhantomEntity.cpp
src/Game/Entities/entities/monster/PigZombieEntity.cpp
src/Game/Entities/entities/animal/PigEntity.cpp
src/Game/Entities/entities/monster/piglin/PiglinEntity.cpp
src/Game/Entities/entities/monster/piglin/PiglinBruteEntity.cpp
src/Game/Entities/entities/monster/PillagerEntity.cpp
src/Game/Entities/entities/animal/PolarBearEntity.cpp
src/Game/Entities/entities/item/PrimedTntEntity.cpp
src/Game/Entities/entities/animal/PufferfishEntity.cpp
src/Game/Entities/entities/animal/RabbitEntity.cpp
src/Game/Entities/entities/monster/RavagerEntity.cpp
src/Game/Entities/entities/animal/SalmonEntity.cpp
src/Game/Entities/entities/animal/SheepEntity.cpp
src/Game/Entities/entities/monster/ShulkerEntity.cpp
src/Game/Entities/entities/projectile/ShulkerBulletEntity.cpp
src/Game/Entities/entities/monster/SilverfishEntity.cpp
src/Game/Entities/entities/monster/SkeletonEntity.cpp
src/Game/Entities/entities/animal/horse/SkeletonHorseEntity.cpp
src/Game/Entities/entities/monster/SlimeEntity.cpp
src/Game/Entities/entities/projectile/SmallFireballEntity.cpp
src/Game/Entities/entities/animal/sniffer/SnifferEntity.cpp
src/Game/Entities/entities/animal/SnowGolemEntity.cpp
src/Game/Entities/entities/projectile/SnowballEntity.cpp
src/Game/Entities/entities/projectile/SpectralArrowEntity.cpp
src/Game/Entities/entities/monster/SpiderEntity.cpp
src/Game/Entities/entities/animal/SquidEntity.cpp
src/Game/Entities/entities/monster/StrayEntity.cpp
src/Game/Entities/entities/monster/StriderEntity.cpp
src/Game/Entities/entities/animal/frog/TadpoleEntity.cpp
src/Game/Entities/entities/projectile/ThrownEggEntity.cpp
src/Game/Entities/entities/projectile/ThrownEnderpearlEntity.cpp
src/Game/Entities/entities/projectile/ThrownExperienceBottleEntity.cpp
src/Game/Entities/entities/projectile/ThrownPotionEntity.cpp
src/Game/Entities/entities/projectile/ThrownTridentEntity.cpp
src/Game/Entities/entities/animal/horse/TraderLlamaEntity.cpp
src/Game/Entities/entities/animal/TropicalFishEntity.cpp
src/Game/Entities/entities/animal/TurtleEntity.cpp
src/Game/Entities/entities/monster/VexEntity.cpp
src/Game/Entities/entities/npc/VillagerEntity.cpp
src/Game/Entities/entities/monster/VindicatorEntity.cpp
src/Game/Entities/entities/npc/WanderingTraderEntity.cpp
src/Game/Entities/entities/projectile/WindChargeEntity.cpp
src/Game/Entities/entities/monster/warden/WardenEntity.cpp
src/Game/Entities/entities/monster/WitchEntity.cpp
src/Game/Entities/entities/boss/wither/WitherBossEntity.cpp
src/Game/Entities/entities/monster/WitherSkeletonEntity.cpp
src/Game/Entities/entities/projectile/WitherSkullEntity.cpp
src/Game/Entities/entities/animal/WolfEntity.cpp
src/Game/Entities/entities/monster/ZoglinEntity.cpp
src/Game/Entities/entities/monster/ZombieEntity.cpp
src/Game/Entities/entities/animal/horse/ZombieHorseEntity.cpp
src/Game/Entities/entities/monster/ZombieVillagerEntity.cpp
src/Game/Entities/entities/monster/ZombifiedPiglinEntity.cpp
src/Game/Entities/entities/player/PlayerEntity.cpp
src/Game/Entities/entities/projectile/FishingHookEntity.cpp
src/Game/Entities/entities/Entity.cpp
src/Game/Entities/entities/LivingEntity.cpp
src/Game/Entities/entities/projectile/AbstractArrowEntity.cpp
src/Game/Entities/entities/animal/AnimalEntity.cpp
src/Game/Entities/entities/ambient/AmbientCreatureEntity.cpp
src/Game/Entities/entities/monster/MonsterEntity.cpp
src/Game/Entities/entities/TamableAnimalEntity.cpp
src/Game/Entities/entities/animal/AbstractSchoolingFishEntity.cpp
src/Game/Entities/entities/animal/WaterAnimalEntity.cpp
src/Game/Entities/entities/animal/horse/AbstractChestedHorseEntity.cpp
src/Game/Entities/entities/projectile/AbstractHurtingProjectileEntity.cpp
src/Game/Entities/entities/MobEntity.cpp
src/Game/Entities/entities/monster/SpellcasterIllagerEntity.cpp
src/Game/Entities/entities/projectile/ProjectileEntity.cpp
src/Game/Entities/entities/FlyingMobEntity.cpp
src/Game/Entities/entities/animal/horse/AbstractHorseEntity.cpp
src/Game/Entities/entities/animal/AbstractGolemEntity.cpp
src/Game/Entities/entities/decoration/HangingEntity.cpp
src/Game/Entities/entities/projectile/FireballEntity.cpp
src/Game/Entities/entities/vehicle/AbstractMinecartEntity.cpp
src/Game/Entities/entities/vehicle/AbstractMinecartContainerEntity.cpp
src/Game/Entities/entities/vehicle/VehicleEntity.cpp
src/Game/Entities/entities/animal/ShoulderRidingEntity.cpp
src/Game/Entities/entities/monster/piglin/AbstractPiglinEntity.cpp
src/Game/Entities/entities/monster/AbstractIllagerEntity.cpp
src/Game/Entities/entities/animal/AbstractFishEntity.cpp
src/Game/Entities/entities/raid/RaiderEntity.cpp
src/Game/Entities/entities/monster/AbstractSkeletonEntity.cpp
src/Game/Entities/entities/projectile/ThrowableItemProjectileEntity.cpp
src/Game/Entities/entities/npc/AbstractVillagerEntity.cpp
src/Game/Entities/entities/AgeableMobEntity.cpp
src/Game/Entities/entities/PathfinderMobEntity.cpp
src/Game/Entities/entities/monster/PatrollingMonsterEntity.cpp
src/Game/Entities/entities/projectile/ThrowableProjectileEntity.cpp
src/Game/Physics/AABB.cpp
src/Game/Physics/PhysicsManager.cpp
src/Network/AESEncrypter.cpp
src/Network/Authentifier.cpp
src/Network/Compression.cpp
src/Network/LastSeenMessagesTracker.cpp
src/Network/NetworkManager.cpp
src/Network/TCP_Com.cpp
src/Utilities/DemanglingUtilities.cpp
src/Utilities/Logger.cpp
src/Utilities/NBTUtilities.cpp
src/Utilities/SleepUtilities.cpp
src/Utilities/StdAnyUtilities.cpp
src/Utilities/StringUtilities.cpp
)
if(BOTCRAFT_USE_OPENGL_GUI)
list(APPEND botcraft_PUBLIC_HDR
include/botcraft/Renderer/RenderingManager.hpp
include/botcraft/Renderer/Enums.hpp
include/botcraft/Renderer/Face.hpp
include/botcraft/Renderer/Transformation.hpp
)
list(APPEND botcraft_PRIVATE_HDR
private_include/botcraft/Renderer/Atlas.hpp
private_include/botcraft/Renderer/BehaviourRenderer.hpp
private_include/botcraft/Renderer/BlockRenderable.hpp
private_include/botcraft/Renderer/Camera.hpp
private_include/botcraft/Renderer/Chunk.hpp
private_include/botcraft/Renderer/Entity.hpp
private_include/botcraft/Renderer/ImageSaver.hpp
private_include/botcraft/Renderer/Shader.hpp
private_include/botcraft/Renderer/TransparentChunk.hpp
private_include/botcraft/Renderer/WorldRenderer.hpp
)
list(APPEND botcraft_SRC
src/Renderer/Atlas.cpp
src/Renderer/BehaviourRenderer.cpp
src/Renderer/BlockRenderable.cpp
src/Renderer/Camera.cpp
src/Renderer/Chunk.cpp
src/Renderer/Entity.cpp
src/Renderer/RenderingManager.cpp
src/Renderer/Face.cpp
src/Renderer/ImageSaver.cpp
src/Renderer/Shader.cpp
src/Renderer/Transformation.cpp
src/Renderer/TransparentChunk.cpp
src/Renderer/WorldRenderer.cpp
)
endif(BOTCRAFT_USE_OPENGL_GUI)
# To have a nice files structure in Visual Studio
if(MSVC)
foreach(source IN LISTS botcraft_PUBLIC_HDR)
get_filename_component(source_path_header "${source}" PATH)
string(REPLACE "include/botcraft" "Header Files/public" source_path_header "${source_path_header}")
string(REPLACE "/" "\\" source_path_msvc "${source_path_header}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
foreach(source IN LISTS botcraft_PRIVATE_HDR)
get_filename_component(source_path_header "${source}" PATH)
string(REPLACE "private_include/botcraft" "Header Files/private" source_path_header "${source_path_header}")
string(REPLACE "/" "\\" source_path_msvc "${source_path_header}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
foreach(source IN LISTS botcraft_SRC)
get_filename_component(source_path "${source}" PATH)
string(REPLACE "src" "Source Files" source_path "${source_path}")
string(REPLACE "/" "\\" source_path_msvc "${source_path}")
source_group("${source_path_msvc}" FILES "${source}")
endforeach()
endif()
add_library(botcraft SHARED ${botcraft_SRC} ${botcraft_PUBLIC_HDR} ${botcraft_PRIVATE_HDR})
set_property(TARGET botcraft PROPERTY CXX_STANDARD 17)
set_target_properties(botcraft PROPERTIES DEBUG_POSTFIX "_d")
set_target_properties(botcraft PROPERTIES RELWITHDEBINFO_POSTFIX "_rd")
# Enable precompiled headers, except on GCC because it's hurting performances
if (BOTCRAFT_USE_PRECOMPILED_HEADERS AND NOT CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_precompile_headers(botcraft PRIVATE
include/botcraft/Game/Entities/entities/Entity.hpp
${protocolCraft_SOURCE_DIR}/include/protocolCraft/AllMessages.hpp
)
endif()
if(MSVC)
# To avoid having folder for each configuration when building with Visual
set_target_properties(botcraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(botcraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(botcraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${BOTCRAFT_OUTPUT_DIR}/lib")
set_target_properties(botcraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${BOTCRAFT_OUTPUT_DIR}/lib")
else()
set_target_properties(botcraft PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin")
set_target_properties(botcraft PROPERTIES ARCHIVE_OUTPUT_DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/lib")
endif(MSVC)
if (MSVC)
target_compile_options(botcraft PRIVATE "$<$<CONFIG:Debug>:/bigobj>")
endif (MSVC)
# Set version header
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/Version.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/include/botcraft/Version.hpp")
if (WIN32)
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_mc_assets.bat.in" "${CMAKE_CURRENT_BINARY_DIR}/download_mc_assets.bat")
else()
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/download_mc_assets.sh.in" "${CMAKE_CURRENT_BINARY_DIR}/download_mc_assets.sh")
endif (WIN32)
# Add include folders
target_include_directories(botcraft
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
PRIVATE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/private_include>"
)
target_compile_definitions(botcraft PRIVATE ASSETS_PATH="${ASSET_DIR}")
# Add DL lib for linux compilation
target_link_libraries(botcraft PUBLIC ${CMAKE_DL_LIBS})
# Add protocolCraft
target_link_libraries(botcraft PUBLIC protocolCraft)
if (WIN32 AND BOTCRAFT_WINDOWS_BETTER_SLEEP)
target_link_libraries(botcraft PRIVATE winmm.lib)
target_compile_definitions(botcraft PRIVATE BETTER_SLEEP=1)
endif()
# Add Asio
target_link_libraries(botcraft PRIVATE asio)
target_compile_definitions(botcraft PRIVATE ASIO_STANDALONE)
# Add threads support
target_link_libraries(botcraft PUBLIC Threads::Threads)
# Add graphical dependencies
if(BOTCRAFT_USE_OPENGL_GUI)
target_link_libraries(botcraft PRIVATE glfw glad glm rectpack2D OpenGL::GL stb_image)
if(BOTCRAFT_USE_IMGUI)
target_link_libraries(botcraft PRIVATE imgui)
target_compile_definitions(botcraft PRIVATE USE_IMGUI=1)
endif()
target_compile_definitions(botcraft PUBLIC USE_GUI=1)
endif(BOTCRAFT_USE_OPENGL_GUI)
if(BOTCRAFT_COMPRESSION)
target_link_libraries(botcraft PRIVATE ZLIB::ZLIB)
target_compile_definitions(botcraft PRIVATE USE_COMPRESSION=1)
endif(BOTCRAFT_COMPRESSION)
if(BOTCRAFT_ENCRYPTION)
target_link_libraries(botcraft PRIVATE OpenSSL::SSL)
target_link_libraries(botcraft PRIVATE OpenSSL::Crypto)
target_compile_definitions(botcraft PRIVATE USE_ENCRYPTION=1)
endif(BOTCRAFT_ENCRYPTION)
if(WIN32 AND MINGW)
target_link_libraries(botcraft PRIVATE ws2_32 crypt32)
# Copy dll from the compiler folder
get_filename_component(COMPILER_FOLDER ${CMAKE_CXX_COMPILER} DIRECTORY)
add_custom_command(TARGET botcraft POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${COMPILER_FOLDER}/libstdc++-6.dll"
$<TARGET_FILE_DIR:botcraft>)
endif()
# Installation stuff
include(GNUInstallDirs)
install(TARGETS botcraft
EXPORT botcraft-targets
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_BINDIR}"
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
if (NOT BOTCRAFT_INSTALL_MC_ASSETS)
if (WIN32)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/download_mc_assets.bat"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
else()
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/download_mc_assets.sh"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif (WIN32)
endif(NOT BOTCRAFT_INSTALL_MC_ASSETS)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/botcraft"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
)
install(FILES
"${CMAKE_CURRENT_BINARY_DIR}/include/botcraft/Version.hpp"
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/botcraft"
)
install(EXPORT botcraft-targets
FILE botcraft-targets.cmake
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/botcraft"
)
include(CMakePackageConfigHelpers)
configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/botcraft-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake/botcraft-config.cmake"
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/botcraft"
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/cmake/botcraft-config.cmake"
DESTINATION
"${CMAKE_INSTALL_LIBDIR}/cmake/botcraft"
)
export(EXPORT botcraft-targets
FILE "${CMAKE_CURRENT_BINARY_DIR}/cmake/botcraft-targets.cmake"
)
# Copy asset files into install binary folder
if (BOTCRAFT_INSTALL_MC_ASSETS)
install(DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin/Assets/${BOTCRAFT_GAME_VERSION}"
DESTINATION "${CMAKE_INSTALL_BINDIR}/Assets"
)
else()
install(DIRECTORY "${BOTCRAFT_OUTPUT_DIR}/bin/Assets/${BOTCRAFT_GAME_VERSION}"
DESTINATION "${CMAKE_INSTALL_BINDIR}/Assets"
PATTERN "minecraft" EXCLUDE
)
endif(BOTCRAFT_INSTALL_MC_ASSETS)
# Copy Mingw libstdc++ dll
if(WIN32 AND MINGW)
install(FILES
"${BOTCRAFT_OUTPUT_DIR}/bin/libstdc++-6.dll"
DESTINATION "${CMAKE_INSTALL_BINDIR}"
)
endif()
+6
View File
@@ -0,0 +1,6 @@
#pragma once
#include <string>
const int protocol_version = ${PROTOCOL_VERSION};
const std::string game_version = "${BOTCRAFT_GAME_VERSION}";
@@ -0,0 +1,7 @@
@PACKAGE_INIT@
find_package(Threads)
if(NOT TARGET botcraft)
include(${CMAKE_CURRENT_LIST_DIR}/botcraft-targets.cmake)
endif()
@@ -0,0 +1,16 @@
if exist Assets\${BOTCRAFT_GAME_VERSION}\minecraft\ (
echo Minecraft ${BOTCRAFT_GAME_VERSION} assets already downloaded
) else (
echo Downloading Minecraft ${BOTCRAFT_GAME_VERSION} assets...
mkdir Assets\${BOTCRAFT_GAME_VERSION}\minecraft\
mkdir tmp
Rem Download ${BOTCRAFT_GAME_VERSION} client file
curl.exe --output tmp\client.jar --url ${VERSION_CLIENT_URL}
Rem Extract the following folders from the jar file: assets/minecraft/blockstates assets/minecraft/models/block assets/minecraft/textures/block assets/minecraft/textures/entity
tar.exe -x -f tmp\client.jar -C tmp assets/minecraft/blockstates assets/minecraft/models/block assets/minecraft/textures/block assets/minecraft/textures/entity
Rem copy the folders to correct destination
xcopy /s tmp\assets\minecraft\ Assets\${BOTCRAFT_GAME_VERSION}\minecraft\
Rem clean
rmdir /s /q tmp
echo Done!
)
@@ -0,0 +1,14 @@
#!/bin/bash
if [ -d "Assets/${BOTCRAFT_GAME_VERSION}/minecraft/" ]
then
echo "Minecraft ${BOTCRAFT_GAME_VERSION} assets already downloaded"
else
echo "Downloading Minecraft ${BOTCRAFT_GAME_VERSION} assets..."
mkdir tmp/
curl --output tmp/client.jar --url ${VERSION_CLIENT_URL}
unzip -q tmp/client.jar -d tmp/ 'assets/minecraft/blockstates/**' 'assets/minecraft/models/block/**' 'assets/minecraft/textures/block/**' 'assets/minecraft/textures/entity/**'
cp -r tmp/assets/minecraft/ Assets/${BOTCRAFT_GAME_VERSION}/
rm -rf ./tmp/
echo Done!
fi
@@ -0,0 +1,33 @@
#pragma once
#include <string>
namespace Botcraft
{
enum class BehaviourNodeType
{
Tree,
Leaf,
Composite,
Decorator
};
class BaseNode
{
public:
BaseNode(const std::string& name_);
virtual ~BaseNode();
// Helper functions not directly related to behaviour trees
// but useful to work with the tree structure
virtual BehaviourNodeType GetNodeType() const = 0;
virtual size_t GetNumChildren() const = 0;
virtual const BaseNode* GetChild(const size_t index) const = 0;
std::string GetFullDescriptor() const;
const std::string& GetName() const;
std::string GetClassName() const;
protected:
const std::string name;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/ManagersClient.hpp"
#include "botcraft/AI/Blackboard.hpp"
namespace Botcraft
{
/// @brief A ManagersClient extended with a blackboard that can store any
/// kind of data and a virtual Yield function.
/// You should **not** inherit from this class, but from TemplatedBehaviourClient
/// or SimpleBehaviourClient instead.
class BehaviourClient : public ManagersClient, private BlackboardObserver
{
public:
BehaviourClient(const bool use_renderer_);
virtual ~BehaviourClient();
virtual void Yield() = 0;
Blackboard& GetBlackboard();
public:
void OnReset() override;
void OnValueChanged(const std::string& key, const std::any& value) override;
void OnValueRemoved(const std::string& key) override;
protected:
Blackboard blackboard;
};
} // namespace Botcraft
@@ -0,0 +1,863 @@
#pragma once
#include <vector>
#include <memory>
#include <functional>
#include <string>
#include <stdexcept>
#include "botcraft/AI/BaseNode.hpp"
#include "botcraft/AI/Status.hpp"
#include "botcraft/Utilities/Templates.hpp"
// A behaviour tree implementation following this blog article
// https://www.gamasutra.com/blogs/ChrisSimpson/20140717/221339/Behavior_trees_for_AI_How_they_work.php
// First version of this code was inspired by
// https://github.com/arvidsson/BrainTree
namespace Botcraft
{
// Define some templates functions used as update
// notifications during node ticking
GENERATE_CHECK_HAS_FUNC(OnNodeStartTick);
GENERATE_CHECK_HAS_FUNC(OnNodeEndTick);
GENERATE_CHECK_HAS_FUNC(OnNodeTickChild);
template<typename Context>
class Node : public BaseNode
{
using BaseNode::BaseNode;
public:
virtual ~Node() {}
Status Tick(Context& context) const
{
if constexpr (has_OnNodeStartTick<Context, void()>)
{
context.OnNodeStartTick();
}
const Status result = this->TickImpl(context);
if constexpr (has_OnNodeEndTick<Context, void(Status)>)
{
context.OnNodeEndTick(result);
}
return result;
}
protected:
virtual Status TickImpl(Context& context) const = 0;
};
template<typename Context>
class Composite : public Node<Context>
{
using Node<Context>::Node;
public:
virtual ~Composite() {}
void AddChild(const std::shared_ptr<Node<Context>>& child)
{
children.push_back(child);
}
virtual BehaviourNodeType GetNodeType() const override
{
return BehaviourNodeType::Composite;
}
virtual size_t GetNumChildren() const override
{
return children.size();
}
virtual const BaseNode* GetChild(const size_t index) const override
{
return children[index].get();
}
protected:
Status TickChild(Context& context, const size_t index) const
{
if (index >= children.size())
{
throw std::runtime_error(std::string("Out of bounds child ticking in ") + this->GetFullDescriptor() + " at index " + std::to_string(index));
}
if (children[index] == nullptr)
{
throw std::runtime_error(std::string("Nullptr child in ") + this->GetFullDescriptor() + " at index " + std::to_string(index));
}
if constexpr (has_OnNodeTickChild<Context, void(size_t)>)
{
context.OnNodeTickChild(index);
}
try
{
return children[index]->Tick(context);
}
catch (const std::exception& ex)
{
throw std::runtime_error(std::string("In ") + this->GetFullDescriptor() + " while Ticking child " + std::to_string(index) + "\n" +
ex.what());
}
}
private:
std::vector<std::shared_ptr<Node<Context>>> children;
};
template<typename Context>
class Decorator : public Node<Context>
{
using Node<Context>::Node;
public:
virtual ~Decorator() {}
void SetChild(std::shared_ptr<Node<Context>> child_)
{
child = child_;
}
virtual BehaviourNodeType GetNodeType() const override
{
return BehaviourNodeType::Decorator;
}
virtual size_t GetNumChildren() const override
{
return child == nullptr ? 0 : 1;
}
virtual const BaseNode* GetChild(const size_t index) const override
{
return child.get();
}
protected:
Status TickChild(Context& context) const
{
if (child == nullptr)
{
throw std::runtime_error("Nullptr child in decorator " + this->GetFullDescriptor());
}
if constexpr (has_OnNodeTickChild<Context, void(size_t)>)
{
context.OnNodeTickChild(0);
}
try
{
return child->Tick(context);
}
catch (const std::exception& ex)
{
throw std::runtime_error(std::string("In ") + this->GetFullDescriptor() + "\n" +
ex.what());
}
}
private:
std::shared_ptr<Node<Context>> child;
};
template<typename Context>
class Leaf final : public Node<Context>
{
public:
Leaf() = delete;
template<typename FuncType>
Leaf(const std::string& s, FuncType func_) : Node<Context>(s), func(func_) {}
template<typename FuncType, typename... Args>
Leaf(const std::string& s, FuncType func_, Args&&... args) : Node<Context>(s)
{
func = [=](Context& c) -> Status { return func_(c, (args)...); };
}
virtual ~Leaf() {}
virtual BehaviourNodeType GetNodeType() const override
{
return BehaviourNodeType::Leaf;
}
virtual size_t GetNumChildren() const override
{
return 0;
}
virtual const BaseNode* GetChild(const size_t index) const override
{
return nullptr;
}
protected:
virtual Status TickImpl(Context& context) const override
{
try
{
return func(context);
}
catch (const std::exception& ex)
{
if (this->name.empty())
{
throw;
}
throw std::runtime_error(std::string("In leaf \"") + this->name + "\"\n" +
ex.what());
}
}
private:
std::function<Status(Context&)> func;
};
template<typename Context>
class BehaviourTree final : public Node<Context>
{
using Node<Context>::Node;
public:
virtual ~BehaviourTree() {}
void SetRoot(const std::shared_ptr<Node<Context>> node) { root = node; }
virtual BehaviourNodeType GetNodeType() const override
{
return BehaviourNodeType::Tree;
}
virtual size_t GetNumChildren() const override
{
return root == nullptr ? 0 : 1;
}
virtual const BaseNode* GetChild(const size_t index) const override
{
return root.get();
}
protected:
virtual Status TickImpl(Context& context) const override
{
if (root == nullptr)
{
throw std::runtime_error(std::string("Nullptr tree when trying to tick tree ") + this->GetFullDescriptor());
}
if constexpr (has_OnNodeTickChild<Context, void(size_t)>)
{
context.OnNodeTickChild(0);
}
try
{
return root->Tick(context);
}
catch (const std::exception& ex)
{
if (this->name.empty())
{
throw;
}
throw std::runtime_error(std::string("In tree \"") + this->name + "\"\n" +
ex.what());
}
}
private:
std::shared_ptr<Node<Context>> root;
};
/// @brief Sequence implementation. Run all children until
/// one fails. Succeeds if all children succeed.
/// Equivalent to a logical AND.
/// @tparam Context The tree context type
template<typename Context>
class Sequence final : public Composite<Context>
{
using Composite<Context>::Composite;
protected:
virtual Status TickImpl(Context& context) const override
{
for (size_t i = 0; i < this->GetNumChildren(); ++i)
{
if (this->TickChild(context, i) == Status::Failure)
{
return Status::Failure;
}
}
// If we are here, all children succeeded
return Status::Success;
}
};
/// @brief Selector implementation. Run all children until
/// one succeeds. Fails if all children fail.
/// Equivalent to a logical OR.
/// @tparam Context The tree context type
template<typename Context>
class Selector final : public Composite<Context>
{
using Composite<Context>::Composite;
protected:
virtual Status TickImpl(Context& context) const override
{
for (size_t i = 0; i < this->GetNumChildren(); ++i)
{
if (this->TickChild(context, i) == Status::Success)
{
return Status::Success;
}
}
// If we are here, all children failed
return Status::Failure;
}
};
// Common Decorators implementations
/// @brief A Decorator that inverts the result of its child.
/// @tparam Context The tree context type
template<typename Context>
class Inverter final : public Decorator<Context>
{
using Decorator<Context>::Decorator;
protected:
virtual Status TickImpl(Context& context) const override
{
return this->TickChild(context) == Status::Failure ? Status::Success : Status::Failure;
}
};
/// @brief A Decorator that always return success,
/// independently of the result of its child.
/// Can be combined with an inverter for Failure.
/// @tparam Context The tree context type
template<typename Context>
class Succeeder final : public Decorator<Context>
{
using Decorator<Context>::Decorator;
protected:
virtual Status TickImpl(Context& context) const override
{
this->TickChild(context);
return Status::Success;
}
};
/// @brief A Decorator that ticks its child n times
/// (repeat until first success if n == 0).
/// Always returns success.
/// @tparam Context The tree context type
template<typename Context>
class Repeater final : public Decorator<Context>
{
public:
Repeater(const std::string& s, const size_t n_) : Decorator<Context>(s), n(n_) {}
protected:
virtual Status TickImpl(Context& context) const override
{
Status child_status = Status::Failure;
size_t counter = 0;
while ((child_status == Status::Failure && n == 0) || counter < n)
{
child_status = this->TickChild(context);
counter += 1;
}
return Status::Success;
}
private:
size_t n;
};
// Builder implementation for easy tree building
template<typename Parent, typename Context>
class DecoratorBuilder;
template<typename Context>
class Builder;
template<typename Parent, typename Context>
class CompositeBuilder
{
public:
CompositeBuilder(Parent* parent, Composite<Context>* node) : parent(parent), node(node) {}
/// @brief To add a named leaf
/// @tparam S std::string convertible type
/// @tparam ...Args leaf function and params
/// @tparam Do not use this template if first param is not a string
/// @param s Leaf name
/// @param ...args leaf function and params
/// @return A composite builder to continue building the tree
template<
typename S,
typename... Args,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
CompositeBuilder leaf(const S& s, Args&&... args)
{
auto child = std::make_shared<Leaf<Context> >(s, std::forward<Args>(args)...);
node->AddChild(child);
return *this;
}
/// @brief To add an anonymous leaf
/// @tparam ...Args
/// @param ...args
/// @return
template<typename... Args>
CompositeBuilder leaf(Args&&... args)
{
auto child = std::make_shared<Leaf<Context> >("", std::forward<Args>(args)...);
node->AddChild(child);
return *this;
}
// To add a tree
CompositeBuilder tree(std::shared_ptr<BehaviourTree<Context> > arg)
{
node->AddChild(arg);
return *this;
}
// Composite
// Custom function to add a sequence
CompositeBuilder<CompositeBuilder, Context> sequence(const std::string& s = "")
{
auto child = std::make_shared<Sequence<Context>>(s);
node->AddChild(child);
return CompositeBuilder<CompositeBuilder, Context>(this, (Sequence<Context>*)child.get());
}
// Custom function to add a selector
CompositeBuilder<CompositeBuilder, Context> selector(const std::string& s = "")
{
auto child = std::make_shared<Selector<Context>>(s);
node->AddChild(child);
return CompositeBuilder<CompositeBuilder, Context>(this, (Selector<Context>*)child.get());
}
// To add any other type of composite
template<
typename CompositeType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
CompositeBuilder<CompositeBuilder, Context> composite(const S& s, Args&&... args)
{
auto child = std::make_shared<CompositeType>(s, std::forward<Args>(args)...);
node->AddChild(child);
return CompositeBuilder<CompositeBuilder, Context>(this, (CompositeType*)child.get());
}
template<
typename CompositeType,
typename... Args
>
CompositeBuilder<CompositeBuilder, Context> composite(Args&&... args)
{
auto child = std::make_shared<CompositeType>("", std::forward<Args>(args)...);
node->AddChild(child);
return CompositeBuilder<CompositeBuilder, Context>(this, (CompositeType*)child.get());
}
// Decorator
// Inverter
DecoratorBuilder<CompositeBuilder, Context> inverter(const std::string& s = "")
{
auto child = std::make_shared<Inverter<Context>>(s);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (Inverter<Context>*)child.get());
}
// Succeeder
DecoratorBuilder<CompositeBuilder, Context> succeeder(const std::string& s = "")
{
auto child = std::make_shared<Succeeder<Context>>(s);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (Succeeder<Context>*)child.get());
}
// Repeater
DecoratorBuilder<CompositeBuilder, Context> repeater(const size_t n)
{
auto child = std::make_shared<Repeater<Context>>("", n);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (Repeater<Context>*)child.get());
}
// Repeater
DecoratorBuilder<CompositeBuilder, Context> repeater(const std::string& s, const size_t n)
{
auto child = std::make_shared<Repeater<Context>>(s, n);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (Repeater<Context>*)child.get());
}
// To add any other type of decorator
template<
typename DecoratorType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
DecoratorBuilder<CompositeBuilder, Context> decorator(const S& s, Args&&... args)
{
auto child = std::make_shared<DecoratorType>(s, std::forward<Args>(args)...);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (DecoratorType*)child.get());
}
template<
typename DecoratorType,
typename... Args
>
DecoratorBuilder<CompositeBuilder, Context> decorator(Args&&... args)
{
auto child = std::make_shared<DecoratorType>("", std::forward<Args>(args)...);
node->AddChild(child);
return DecoratorBuilder<CompositeBuilder, Context>(this, (DecoratorType*)child.get());
}
std::conditional_t<
std::is_same_v<Parent, Builder<Context>>, // If the parent is a Builder
std::shared_ptr<BehaviourTree<Context>>, // Then return the tree as we can't add anything else after the root
Parent& // Else return the parent to continue the chain
> end()
{
if constexpr (std::is_same_v<Parent, Builder<Context>>)
{
return parent->build();
}
else
{
return *parent;
}
}
private:
Parent* parent;
Composite<Context>* node;
};
template<typename Parent, typename Context>
class DecoratorBuilder
{
public:
DecoratorBuilder(Parent* parent, Decorator<Context>* node) : parent(parent), node(node) {}
// To add a leaf
template<
typename S,
typename... Args,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
std::conditional_t<
std::is_same_v<Parent, Builder<Context>>, // If the parent is a Builder
std::shared_ptr<BehaviourTree<Context>>, // Then return the tree as we can't add anything else after the root
Parent& // Else return the parent to continue the chain
> leaf(const S& s, Args&&... args)
{
auto child = std::make_shared<Leaf<Context> >(s, std::forward<Args>(args)...);
node->SetChild(child);
if constexpr (std::is_same_v<Parent, Builder<Context>>)
{
return parent->build();
}
else
{
return *parent;
}
}
template<typename... Args>
std::conditional_t<
std::is_same_v<Parent, Builder<Context>>, // If the parent is a Builder
std::shared_ptr<BehaviourTree<Context>>, // Then return the tree as we can't add anything else after the root
Parent& // Else return the parent to continue the chain
> leaf(Args&&... args)
{
auto child = std::make_shared<Leaf<Context> >("", std::forward<Args>(args)...);
node->SetChild(child);
if constexpr (std::is_same_v<Parent, Builder<Context>>)
{
return parent->build();
}
else
{
return *parent;
}
}
// To add a tree
std::conditional_t<
std::is_same_v<Parent, Builder<Context>>, // If the parent is a Builder
std::shared_ptr<BehaviourTree<Context>>, // Then return the tree as we can't add anything else after the root
Parent& // Else return the parent to continue the chain
> tree(std::shared_ptr<BehaviourTree<Context> > arg)
{
node->SetChild(arg);
if constexpr (std::is_same_v<Parent, Builder<Context>>)
{
return parent->build();
}
else
{
return *parent;
}
}
// Composites
// Custom function to add a sequence
CompositeBuilder<Parent, Context> sequence(const std::string& s = "")
{
auto child = std::make_shared<Sequence<Context>>(s);
node->SetChild(child);
return CompositeBuilder<Parent, Context>(parent, (Sequence<Context>*)child.get());
}
// Custom function to add a selector
CompositeBuilder<Parent, Context> selector(const std::string& s = "")
{
auto child = std::make_shared<Selector<Context>>(s);
node->SetChild(child);
return CompositeBuilder<Parent, Context>(parent, (Selector<Context>*)child.get());
}
// To add any other type of composite
template<
typename CompositeType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
CompositeBuilder<Parent, Context> composite(const S& s, Args&&... args)
{
auto child = std::make_shared<CompositeType>(s, std::forward<Args>(args)...);
node->SetChild(child);
return CompositeBuilder<Parent, Context>(parent, (CompositeType*)child.get());
}
template<
typename CompositeType,
typename... Args
>
CompositeBuilder<Parent, Context> composite(Args&&... args)
{
auto child = std::make_shared<CompositeType>("", std::forward<Args>(args)...);
node->SetChild(child);
return CompositeBuilder<Parent, Context>(parent, (CompositeType*)child.get());
}
// Decorator
// Inverter
DecoratorBuilder<Parent, Context> inverter(const std::string& s = "")
{
auto child = std::make_shared<Inverter<Context>>(s);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (Inverter<Context>*)child.get());
}
// Succeeder
DecoratorBuilder<Parent, Context> succeeder(const std::string& s = "")
{
auto child = std::make_shared<Succeeder<Context>>(s);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (Succeeder<Context>*)child.get());
}
// Repeater
DecoratorBuilder<Parent, Context> repeater(const size_t n)
{
auto child = std::make_shared<Repeater<Context>>("", n);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (Repeater<Context>*)child.get());
}
// Repeater
DecoratorBuilder<Parent, Context> repeater(const std::string& s, const size_t n)
{
auto child = std::make_shared<Repeater<Context>>(s, n);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (Repeater<Context>*)child.get());
}
// To add any other type of decorator
template<
typename DecoratorType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
DecoratorBuilder<Parent, Context> decorator(const S& s, Args&&... args)
{
auto child = std::make_shared<DecoratorType>(s, std::forward<Args>(args)...);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (DecoratorType*)child.get());
}
template<
typename DecoratorType,
typename... Args
>
DecoratorBuilder<Parent, Context> decorator(Args&&... args)
{
auto child = std::make_shared<DecoratorType>("", std::forward<Args>(args)...);
node->SetChild(child);
return DecoratorBuilder<Parent, Context>(parent, (DecoratorType*)child.get());
}
private:
Parent* parent;
Decorator<Context>* node;
};
// Now that we have CompositeBuilder and DecoratorBuilder
// we can define the main Builder class
template<typename Context>
class Builder
{
public:
Builder(const std::string& name = "") : root(nullptr), root_name(name) {}
template<
typename S,
typename... Args,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
std::shared_ptr<BehaviourTree<Context>> leaf(const S& s, Args&&... args)
{
auto tree = std::make_shared<BehaviourTree<Context> >(root_name);
tree->SetRoot(std::make_shared<Leaf<Context> >(s, std::forward<Args>(args)...));
return tree;
}
template<typename... Args>
std::shared_ptr<BehaviourTree<Context>> leaf(Args&&... args)
{
auto tree = std::make_shared<BehaviourTree<Context> >(root_name);
tree->SetRoot(std::make_shared<Leaf<Context> >("", std::forward<Args>(args)...));
return tree;
}
// Composites
// Custom function to add a sequence
CompositeBuilder<Builder, Context> sequence(const std::string& s = "")
{
root = std::make_shared<Sequence<Context>>(s);
return CompositeBuilder<Builder, Context>(this, (Sequence<Context>*)root.get());
}
// Custom function to add a selector
CompositeBuilder<Builder, Context> selector(const std::string& s = "")
{
root = std::make_shared<Selector<Context>>(s);
return CompositeBuilder<Builder, Context>(this, (Selector<Context>*)root.get());
}
// To add any other type of composite
template<
typename CompositeType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
CompositeBuilder<Builder, Context> composite(const S& s, Args&&... args)
{
root = std::make_shared<CompositeType>(s, std::forward<Args>(args)...);
return CompositeBuilder<Builder, Context>(this, (CompositeType*)root.get());
}
template<
typename CompositeType,
typename... Args
>
CompositeBuilder<Builder, Context> composite(Args&&... args)
{
root = std::make_shared<CompositeType>("", std::forward<Args>(args)...);
return CompositeBuilder<Builder, Context>(this, (CompositeType*)root.get());
}
// Decorator
// Inverter
DecoratorBuilder<Builder, Context> inverter(const std::string& s = "")
{
root = std::make_shared<Inverter<Context>>(s);
return DecoratorBuilder<Builder, Context>(this, (Inverter<Context>*)root.get());
}
// Succeeder
DecoratorBuilder<Builder, Context> succeeder(const std::string& s = "")
{
root = std::make_shared<Succeeder<Context>>(s);
return DecoratorBuilder<Builder, Context>(this, (Succeeder<Context>*)root.get());
}
// Repeater
DecoratorBuilder<Builder, Context> repeater(const size_t n)
{
root = std::make_shared<Repeater<Context>>("", n);
return DecoratorBuilder<Builder, Context>(this, (Repeater<Context>*)root.get());
}
// Repeater
DecoratorBuilder<Builder, Context> repeater(const std::string& s, const size_t n)
{
root = std::make_shared<Repeater<Context>>(s, n);
return DecoratorBuilder<Builder, Context>(this, (Repeater<Context>*)root.get());
}
// To add any other type of decorator
template<
typename DecoratorType,
typename... Args,
typename S,
typename = typename std::enable_if_t<std::is_convertible_v<S, std::string>>
>
DecoratorBuilder<Builder, Context> decorator(const S& s, Args&&... args)
{
root = std::make_shared<DecoratorType>(s, std::forward<Args>(args)...);
return DecoratorBuilder<Builder, Context>(this, (DecoratorType*)root.get());
}
template<
typename DecoratorType,
typename... Args
>
DecoratorBuilder<Builder, Context> decorator(Args&&... args)
{
root = std::make_shared<DecoratorType>("", std::forward<Args>(args)...);
return DecoratorBuilder<Builder, Context>(this, (DecoratorType*)root.get());
}
private:
std::shared_ptr<BehaviourTree<Context> > build()
{
auto tree = std::make_shared<BehaviourTree<Context> >(root_name);
tree->SetRoot(root);
return tree;
}
friend DecoratorBuilder<Builder, Context>;
friend CompositeBuilder<Builder, Context>;
private:
const std::string root_name;
std::shared_ptr<Node<Context> > root;
};
} // namespace Botcraft
@@ -0,0 +1,162 @@
#pragma once
#include <map>
#include <unordered_map>
#include <any>
#include <string>
#include <functional>
namespace Botcraft
{
/// @brief Wrapper around a reference that will run a callback on destruct
/// @tparam T Type of the reference
template<typename T>
class NotifyOnEndUseRef
{
public:
NotifyOnEndUseRef(T& r, const std::function<void()>& on_destruct_callback_) : _ref(r), on_destruct_callback(on_destruct_callback_) {}
~NotifyOnEndUseRef()
{
if (on_destruct_callback)
{
on_destruct_callback();
}
}
/// @brief Reference getter. Only works on lvalue to prevent calling it on a temporary object (which would run
/// the callback immediately instead of when going out of scope.
/// @return The wrapped reference
T& ref() const& { return _ref; }
T& ref() const&& = delete;
private:
T& _ref;
std::function<void()> on_destruct_callback;
};
class BlackboardObserver
{
public:
virtual void OnReset() = 0;
virtual void OnValueChanged(const std::string& key, const std::any& value) = 0;
virtual void OnValueRemoved(const std::string& key) = 0;
};
/// @brief A map wrapper to store arbitrary data
class Blackboard
{
public:
Blackboard();
~Blackboard();
/// @brief Get the map value at key, casting it to T.
/// The map has to contains key and it has to be a T.
/// @tparam T Any type, must match the type stored at key
/// @param key key to retrieve the value from
/// @return The stored value
template<class T>
const T& Get(const std::string& key)
{
return std::any_cast<T&>(blackboard.at(key));
}
/// @brief Get the map value at key, casting it to T.
/// If the key is not present in the map, add
/// it with default_value, and returns it.
/// @tparam T Any type, must match the type stored at key
/// @param key key to retrieve the value from
/// @param default_value The default value to return if key is not found
/// @return The stored value
template<class T>
const T& Get(const std::string& key, const T& default_value)
{
auto it = blackboard.find(key);
if (it == blackboard.end())
{
it = blackboard.insert(std::pair<std::string, std::any>(key, default_value)).first;
NotifyKeyChanged(key, it->second);
}
return std::any_cast<T&>(it->second);
}
/// @brief Get a ref to the map value at key, casting it to T&. key must exist in the blackboard.
/// Usage example:
/// ```cpp
/// {
/// NotifyOnEndUseRef<int> raw_ref = blackboard.GetRef<int>("key");
/// int& my_ref = raw_ref.ref;
/// my_ref = 8;
/// } // End of scope, raw_ref is destroyed and blackboard is notified value has potentially changed
/// ```
/// @tparam T Any type, must match the type stored at key
/// @param key key to retrieve the value from
/// @return The stored value
template<class T>
NotifyOnEndUseRef<T> GetRef(const std::string& key)
{
return NotifyOnEndUseRef(std::any_cast<T&>(blackboard.at(key)), [this, key]() { NotifyKeyChanged(key, blackboard.at(key)); });
}
/// @brief Get a ref to the map value at key, casting it to T&.
/// If the key is not present in the map, add it with default_value, and returns it.
/// Usage example:
/// ```cpp
/// {
/// NotifyOnEndUseRef<int> raw_ref = blackboard.GetRef<int>("key", 0);
/// int& my_ref = raw_ref.ref;
/// my_ref = 8;
/// } // End of scope, raw_ref is destroyed and blackboard is notified value has potentially changed
/// ```
/// @tparam T Any type, must match the type stored at key
/// @param key key to retrieve the value from
/// @param default_value The default value to return if key is not found
/// @return The stored value
template<class T>
NotifyOnEndUseRef<T> GetRef(const std::string& key, const T& default_value)
{
auto it = blackboard.find(key);
if (it == blackboard.end())
{
it = blackboard.insert(std::pair<std::string, std::any>(key, default_value)).first;
}
return NotifyOnEndUseRef(std::any_cast<T&>(it->second), [this, key]() { NotifyKeyChanged(key, blackboard.at(key)); });
}
/// @brief Set map entry at key to value
/// @tparam T Any type, be careful to be explicit with strings because "foo" is not a std::string but a C-style char*
/// @param key key to store the value at
/// @param value value to store at key
template<class T>
void Set(const std::string& key, const T& value)
{
blackboard[key] = value;
NotifyKeyChanged(key, blackboard[key]);
}
/// @brief Copy a blackboard value
/// @param src Source key, must exist in the blackboard
/// @param dst Destination key
void Copy(const std::string& src, const std::string& dst);
/// @brief Remove a map entry if present
/// @param key key we want to remove
void Erase(const std::string& key);
/// @brief Clear all the entries in the blackboard and load new ones
/// @param values Values to load into the blackboard after clearing
void Reset(const std::map<std::string, std::any>& values = {});
void Subscribe(BlackboardObserver* observer);
void Unsubscribe(BlackboardObserver* observer);
private:
void NotifyCleared() const;
void NotifyKeyRemoved(const std::string& key) const;
void NotifyKeyChanged(const std::string& key, const std::any& value) const;
private:
std::map<std::string, std::any> blackboard;
std::vector<BlackboardObserver*> observers;
};
} // namespace Botcraft
@@ -0,0 +1,17 @@
#pragma once
#include "botcraft/AI/TemplatedBehaviourClient.hpp"
namespace Botcraft
{
/// @brief A client you can use if you only want to use behaviour trees and don't
/// need to add any custom Handle functions. In case you need to react to packets,
/// just inherit either this class, or BaseBehaviourClient the same way it's done here.
class SimpleBehaviourClient : public TemplatedBehaviourClient<SimpleBehaviourClient>
{
public:
SimpleBehaviourClient(const bool use_renderer_);
virtual ~SimpleBehaviourClient();
};
} // namespace Botcraft
@@ -0,0 +1,10 @@
#pragma once
namespace Botcraft
{
enum class Status
{
Failure,
Success
};
}
@@ -0,0 +1,22 @@
#pragma once
/// @brief Base functions you can use as tree leaf
/// in any Botcraft behaviour tree. When a function
/// has some arguments, there are three versions:
/// 1. XXXImpl is the actual task implementation. It
/// is only defined in the cpp file and not available
/// outside of it
/// 2. XXX is the main way to call the task. It will
/// call XXXImpl under the hood after registering its
/// values in the blackboard for easier debugging
/// 3. XXXBlackboard is the same as XXX but will read
/// all parameters from the blackboard (or get default
/// ones)
/// All blackboard variables are saved with the naming
/// convention: FunctionName.param_name
#include "botcraft/AI/Tasks/BaseTasks.hpp"
#include "botcraft/AI/Tasks/DigTask.hpp"
#include "botcraft/AI/Tasks/EntitiesTasks.hpp"
#include "botcraft/AI/Tasks/InventoryTasks.hpp"
#include "botcraft/AI/Tasks/PathfindingTask.hpp"
@@ -0,0 +1,161 @@
#pragma once
#include "botcraft/AI/BehaviourClient.hpp"
#include "botcraft/AI/Status.hpp"
#include "botcraft/Game/Enums.hpp"
#include "botcraft/Game/Vector3.hpp"
namespace Botcraft
{
/// @brief Just call client.Yield(). Can be used to Idle the behaviour.
/// @param client The client performing the action
/// @return Always return Success
Status Yield(BehaviourClient& client);
/// @brief Ask this client to disconnect from the server by setting should_be_closed to true.
/// @param client The client performing the action
/// @return Always return Success
Status Disconnect(BehaviourClient& client);
/// @brief Send a message in the game chat
/// @param client The client performing the action
/// @param msg The message to send
/// @return Always return Success
Status Say(BehaviourClient& client, const std::string& msg);
/// @brief Same thing as Say, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status SayBlackboard(BehaviourClient& client);
/// @brief Interact (right click) with the block at the given location. If too far, will try to pathfind toward it.
/// @param client The client performing the action
/// @param pos The position of the block
/// @param face Face on which we want to clik on
/// @param animation Whether or not we should send an animation to the server (vanilla client does)
/// @return Failure if couldn't interact (because the client couldn't get close enough for example). Success otherwise.
Status InteractWithBlock(BehaviourClient& client, const Position& pos, const PlayerDiggingFace face = PlayerDiggingFace::Up, const bool animation = false);
/// @brief Same thing as InteractWithBlock, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Failure if couldn't interact (because the client couldn't get close enough for example). Success otherwise.
Status InteractWithBlockBlackboard(BehaviourClient& client);
/// @brief Check in the blackboard if the bool at key is true
/// @param client The client performing the action
/// @param key The key to get the bool from
/// @return Success if true, failure if false or not found
Status CheckBlackboardBoolData(BehaviourClient& client, const std::string& key);
/// @brief Same thing as CheckBlackboardBoolData, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if true, failure if false or not found
Status CheckBlackboardBoolDataBlackboard(BehaviourClient& client);
namespace Internal
{
template<typename T>
Status SetBlackboardDataImpl(BehaviourClient& client, const std::string& key, const T& data)
{
client.GetBlackboard().Set(key, data);
return Status::Success;
}
}
/// @brief Set a value in the blackboard
/// @tparam T Any type
/// @param client The client performing the action
/// @param key The key in the blackboard
/// @param data The data to store
/// @return Always return success
template<typename T>
Status SetBlackboardData(BehaviourClient& client, const std::string& key, const T& data)
{
constexpr std::array variable_names = {
"SetBlackboardData.key",
"SetBlackboardData.data"
};
Blackboard& blackboard = client.GetBlackboard();
blackboard.Set<std::string>(variable_names[0], key);
blackboard.Set<T>(variable_names[1], data);
return Internal::SetBlackboardDataImpl<T>(client, key, data);
}
/// @brief Same thing as SetBlackboardData, but reads its parameters from the blackboard
/// @tparam T Any type
/// @param client The client performing the action
/// @return Always return success
template<typename T>
Status SetBlackboardDataBlackboard(BehaviourClient& client)
{
constexpr std::array variable_names = {
"SetBlackboardData.key",
"SetBlackboardData.data"
};
Blackboard& blackboard = client.GetBlackboard();
// Mandatory
const std::string& key = blackboard.Get<std::string>(variable_names[0]);
const T& data = blackboard.Get<T>(variable_names[1]);
return Internal::SetBlackboardDataImpl<T>(client, key, data);
}
/// @brief Remove a value from the blackboard if exist
/// @param client The client performing the action
/// @param key The key to clear
/// @return Always return Success
Status RemoveBlackboardData(BehaviourClient& client, const std::string& key);
/// @brief Same thing as RemoveBlackboardData, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status RemoveBlackboardDataBlackboard(BehaviourClient& client);
/// @brief Return success if player food is below a threshold
/// @param client The client performing the action
/// @param threshold Threshold under which the player is considered to be hungry
/// @return Success if player.GetFood() < threshold, Failure otherwise
Status IsHungry(BehaviourClient& client, const int threshold = 20);
/// @brief Same thing as IsHungry, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if player.GetFood() < threshold, Failure otherwise
Status IsHungryBlackboard(BehaviourClient& client);
/// @brief Copy a blackboard data
/// @param client The client performing the action
/// @param src Source blackboard key
/// @param dst Destination blackboard key
/// @return Always return Success
Status CopyBlackboardData(BehaviourClient& client, const std::string& src, const std::string& dst);
/// @brief Same thing as CopyBlackboardData, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status CopyBlackboardDataBlackboard(BehaviourClient& client);
/// @brief Return Success if it's night time (sleep is possible)
/// @param client The client performing the action
/// @return Success if it's time to sleep, Failure otherwise
Status IsNightTime(BehaviourClient& client);
/// @brief Return success if player is alive
/// @param client The client performing the action
/// @return Success if player.GetHealth() > 0, Failure otherwise
Status IsAlive(BehaviourClient& client);
} // namespace Botcraft
@@ -0,0 +1,23 @@
#pragma once
#include "botcraft/AI/Status.hpp"
#include "botcraft/Game/Vector3.hpp"
#include "botcraft/Game/Enums.hpp"
namespace Botcraft
{
class BehaviourClient;
/// @brief Dig a block at a given location. If too far, will try to pathfind toward it
/// @param c The client performing the action
/// @param pos Location of block to dig
/// @param send_swing If true, will send swing packets to show other players digging in progress
/// @param face Digging direction
/// @return Success if the block is broken, Failure otherwise
Status Dig(BehaviourClient& c, const Position& pos, const bool send_swing = false, const PlayerDiggingFace face = PlayerDiggingFace::Up);
/// @brief Same thing as Dig, but reads its parameters from the blackboard
/// @param c The client performing the action
/// @return Success if the block is broken, Failure otherwise
Status DigBlackboard(BehaviourClient& c);
}
@@ -0,0 +1,22 @@
#pragma once
#include "botcraft/AI/Status.hpp"
#include "botcraft/Game/Enums.hpp"
namespace Botcraft
{
class BehaviourClient;
/// @brief Interact with a given entity. If too far, will try to pathfind to it.
/// @param client The client performing the action
/// @param entity_id The ID of the entity we want to interact with
/// @param hand The hand we want to use
/// @param swing If true, a swing packet will be sent too
/// @return Success if the entity is right clicked (does not mean the server accepted it though). Failure otherwise.
Status InteractEntity(BehaviourClient& client, const int entity_id, const Hand hand = Hand::Main, const bool swing = false);
/// @brief Same thing as InteractEntity, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the entity is right clicked (does not mean the server accepted it though). Failure otherwise.
Status InteractEntityBlackboard(BehaviourClient& client);
}
@@ -0,0 +1,227 @@
#pragma once
#include "botcraft/AI/Status.hpp"
#include "botcraft/Game/Vector3.hpp"
#include "botcraft/Game/Enums.hpp"
#include "botcraft/Utilities/Logger.hpp"
#include "botcraft/Game/Inventory/Item.hpp"
namespace Botcraft
{
class BehaviourClient;
/// @brief Perform a click action on a container
/// @param client The client performing the action
/// @param container_id Container id
/// @param slot_id Clicked slot id
/// @param click_type Type of click (same as in ServerboundContainerClickPacket)
/// @param button_num Button clicked (same as in ServerboundContainerClickPacket)
/// @return Success if the slots is clicked (for versions < 1.17 and the server confirms it), Failure otherwise
Status ClickSlotInContainer(BehaviourClient& client, const short container_id, const short slot_id, const int click_type, const char button_num);
/// @brief Same thing as ClickSlotInContainer, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the slots is clicked (for versions < 1.17 and the server confirms it), Failure otherwise
Status ClickSlotInContainerBlackboard(BehaviourClient& client);
/// @brief Swap two slots in a given container
/// @param client The client performing the action
/// @param container_id Container ID
/// @param first_slot First slot index
/// @param second_slot Second slot index
/// @return Success if the two slots have been correctly swapped, Failure otherwise
Status SwapItemsInContainer(BehaviourClient& client, const short container_id, const short first_slot, const short second_slot);
/// @brief Same thing as SwapItemsInContainer, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the two slots have been correctly swapped, Failure otherwise
Status SwapItemsInContainerBlackboard(BehaviourClient& client);
/// @brief Drop item out of inventory
/// @param client The client performing the action
/// @param container_id Container ID
/// @param slot_id Slot ID
/// @param num_to_keep Number of items to keep in the input slot
/// @return Success if items were correctly dropped, Failure otherwise
Status DropItemsFromContainer(BehaviourClient& client, const short container_id, const short slot_id, const short num_to_keep = 0);
/// @brief Same thing as DropItemsFromContainer, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if items were correctly dropped, Failure otherwise
Status DropItemsFromContainerBlackboard(BehaviourClient& client);
/// @brief Take one item from source_slot, and put it on destination_slot
/// @param client The client performing the action
/// @param container_id Container ID
/// @param source_slot Slot from which the item is taken
/// @param destination_slot Slot receiving the item
/// @return Success if the item is correctly set, Failure otherwise
Status PutOneItemInContainerSlot(BehaviourClient& client, const short container_id, const short source_slot, const short destination_slot);
/// @brief Same thing as PutOneItemInContainerSlot, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the item is correctly set, Failure otherwise
Status PutOneItemInContainerSlotBlackboard(BehaviourClient& client);
/// @brief Try to set a given item in the given hand
/// @param client The client performing the action
/// @param item_name Item name to place in hand
/// @param hand Left or right hand
/// @return Success if the item is now in hand, Failure otherwise
Status SetItemInHand(BehaviourClient& client, const std::string& item_name, const Hand hand = Hand::Right);
/// @brief Same thing as SetItemInHand, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the item is now in hand, Failure otherwise
Status SetItemInHandBlackboard(BehaviourClient& client);
/// @brief Try to place the item at given pos. If too far, will try
/// to pathfind toward the position first.
/// @param client The client performing the action
/// @param item_name The item to place
/// @param pos The location where we want to place the block
/// @param face The face on which the block is placed. If not specified the optimal placing face will be automatically detected using the position of the block relative to the player eyes
/// @param wait_confirmation If true, waits for the server to send the new block in pos
/// @param allow_midair_placing If false, task will fail if the neighbour block matching face is air
/// @return Success if placement attempt was made (and confirmed by the server if wait_confirmation is true), Failure otherwise
Status PlaceBlock(BehaviourClient& client, const std::string& item_name, const Position& pos, std::optional<PlayerDiggingFace> face = std::nullopt, const bool wait_confirmation = false, const bool allow_midair_placing = false);
/// @brief Same thing as PlaceBlock, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if placement attempt was made (and confirmed by the server if wait_confirmation is true), Failure otherwise
Status PlaceBlockBlackboard(BehaviourClient& client);
/// @brief Search for food item in the inventory and eat it
/// @param client The client performing the action
/// @param food_name The item to eat
/// @param wait_confirmation If true, waits for the eaten stack to be reduced by 1 before returning Success
/// @return Success if the item was eaten (and confirmed if wait_confirmation is true), Failure otherwise
Status Eat(BehaviourClient& client, const std::string& food_name, const bool wait_confirmation = true);
/// @brief Same thing as Eat, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the item was eaten (and confirmed if wait_confirmation is true), Failure otherwise
Status EatBlackboard(BehaviourClient& client);
/// @brief Open a container at a given position
/// @param client The client performing the action
/// @param pos The position of the container
/// @return Success if the container is opened, Failure otherwise
Status OpenContainer(BehaviourClient& client, const Position& pos);
/// @brief Same thing as OpenContainer, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the container is opened, Failure otherwise
Status OpenContainerBlackboard(BehaviourClient& client);
/// @brief Close an opened container
/// @param client The client performing the action
/// @param container_id The id of the container to close, if -1, will close the first one found
/// @return Always return Success
Status CloseContainer(BehaviourClient& client, const short container_id = -1);
/// @brief Same thing as CloseContainer, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status CloseContainerBlackboard(BehaviourClient& client);
/// @brief Log all the inventory content at given log level
/// @param client The client performing the action
/// @param level Desired log level
/// @return Always return Success
Status LogInventoryContent(BehaviourClient& client, const LogLevel level = LogLevel::Info);
/// @brief Same thing as LogInventoryContent, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status LogInventoryContentBlackboard(BehaviourClient& client);
#if PROTOCOL_VERSION > 451 /* > 1.13.2 */
/// @brief Buy or sell an item, assuming a trading window is currently opened.
/// @param client The client performing the action
/// @param item_id Id of the item to buy/sell
/// @param buy If true, the item is bought, otherwise is sold
/// @param trade_id If > -1, specify which trade we want to use in the list
/// (useful when the villager sells multiple variants of the same item like
/// enchanted books or bows)
/// @return Success if the exchange went sucessfully, Failure otherwise
Status Trade(BehaviourClient& client, const int item_id, const bool buy, const int trade_id = -1);
/// @brief Same thing as Trade, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the exchange went sucessfully, Failure otherwise
Status TradeBlackboard(BehaviourClient& client);
/// @brief Buy or sell an item, assuming a trading window is currently opened.
/// @param client The client performing the action
/// @param item_name Item to buy/sell
/// @param buy If true, the item is bought, otherwise is sold
/// @param trade_id If > -1, specify which trade we want to use in the list
/// (useful when the villager sells multiple variants of the same item like
/// enchanted books or bows)
/// @return Success if the exchange went sucessfully, Failure otherwise
Status TradeName(BehaviourClient& client, const std::string& item_name, const bool buy, const int trade_id = -1);
/// @brief Same thing as TradeName, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if the exchange went sucessfully, Failure otherwise
Status TradeNameBlackboard(BehaviourClient& client);
#endif
/// @brief Put item in a crafting container and click on the output, storing it in the inventory.
/// @param client The client performing the action
/// @param inputs Input items IDs in a 3x3 grid, inputs[0][1] refers to first line, second column
/// @param allow_inventory_craft If true, the client will use the inventory small 2x2 grid to craft if possible
/// @return Success if item is crafted, Failure otherwise
Status Craft(BehaviourClient& client, const std::array<std::array<ItemId, 3>, 3>& inputs, const bool allow_inventory_craft = true);
/// @brief Same thing as Craft, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if item is crafted, Failure otherwise
Status CraftBlackboard(BehaviourClient& client);
/// @brief Put item in a crafting container and click on the output, storing it in the inventory.
/// @param client The client performing the action
/// @param inputs Input items names in a 3x3 grid, inputs[0][1] refers to first line, second column
/// @param allow_inventory_craft If true, the client will use the inventory small 2x2 grid to craft if possible
/// @return Success if item is crafted, Failure otherwise
Status CraftNamed(BehaviourClient& client, const std::array<std::array<std::string, 3>, 3>& inputs, const bool allow_inventory_craft = true);
/// @brief Same thing as CraftNamed, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if item is crafted, Failure otherwise
Status CraftNamedBlackboard(BehaviourClient& client);
/// @brief Check if item_name is present in inventory
/// @param client The client performing the action
/// @param item_name Item name
/// @param quantity Min quantity to have
/// @return Success if inventory quantity is >= quantity else Failure
Status HasItemInInventory(BehaviourClient& client, const std::string& item_name, const int quantity = 1);
/// @brief Same thing as HasItemInInventory, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if inventory quantity is >= quantity else Failure
Status HasItemInInventoryBlackboard(BehaviourClient& client);
/// @brief Clean the inventory stacking same items together
/// @param client The client performing the action
/// @return Success if no operation failed, Failure otherwise
Status SortInventory(BehaviourClient& client);
}
@@ -0,0 +1,60 @@
#pragma once
#include "botcraft/AI/Status.hpp"
#include "botcraft/Game/Vector3.hpp"
namespace Botcraft
{
class BehaviourClient;
/// @brief Not actually a task. Helper function to compute path between start and end. Does not perfom any movement.
/// @param client Client used to do the pathfinding
/// @param start Start position
/// @param end End position
/// @param dist_tolerance Stop the search earlier if you get closer than dist_tolerance from the end position
/// @param min_end_dist Desired minimal checkboard distance between the final position and goal (useful if you want to place a block, you don't want to be at the exact spot, but close to it).
/// @param min_end_dist_xz Same as min_end_dist but only considering the XZ plane (allows to ask to stand next to a block, but above for example)
/// @param allow_jump If true, allow to jump above 1-wide gaps
/// @return A vector of positions to go through to reach end +/- min_end_dist. If not possible, will return a path to get as close as possible
std::vector<Position> FindPath(const BehaviourClient& client, const Position& start, const Position& end, const int dist_tolerance, const int min_end_dist, const int min_end_dist_xz, const bool allow_jump);
/// @brief Find a path to a position and navigate to it.
/// @param client The client performing the action
/// @param goal The end goal
/// @param dist_tolerance If != 0 and the distance between final position and goal is < dist_tolerance, return Success even if goal is not reached.
/// @param min_end_dist Desired minimal checkboard distance between the final position and goal (useful if you want to place a block, you don't want to be at the exact spot, but close to it). Should always be <= dist_tolerance.
/// @param min_end_dist_xz Same as min_end_dist but only considering the XZ plane (allows to ask to stand next to a block, but above for example)
/// @param allow_jump If true, allow to jump above 1-wide gaps
/// @param sprint If true, the bot will sprint/swim when possible
/// @param speed_factor Multiply vanilla speed if different from 1.0
/// @return Success if goal is reached, Failure otherwise
Status GoTo(BehaviourClient& client, const Position& goal, const int dist_tolerance = 0, const int min_end_dist = 0, const int min_end_dist_xz = 0, const bool allow_jump = true, const bool sprint = true, const float speed_factor = 1.0f);
/// @brief Same thing as GoTo, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Success if goal is reached, Failure otherwise
Status GoToBlackboard(BehaviourClient& client);
/// @brief Turn the camera to look at a given target and send the new rotation to the server
/// @param client The client performing the action
/// @param target The target to look at
/// @param set_pitch If false, only the yaw will be changed
/// @return Always return Success
Status LookAt(BehaviourClient& client, const Vector3<double>& target, const bool set_pitch = true);
/// @brief Same thing as LookAt, but reads its parameters from the blackboard
/// @param client The client performing the action
/// @return Always return Success
Status LookAtBlackboard(BehaviourClient& client);
/// @brief Make the current player fly (as in creative/spectator mode, NOT WITH ELYTRA)
/// @param client The client performing the action
/// @return Success if the player is now flying, failure otherwise
Status StartFlying(BehaviourClient& client);
/// @brief Make the current player not fly (as in creative/spectator mode, NOT WITH ELYTRA)
/// @param client The client performing the action
/// @return Success if the player is now not flying anymore, failure otherwise
Status StopFlying(BehaviourClient& client);
} // namespace Botcraft
@@ -0,0 +1,324 @@
#pragma once
#include <atomic>
#include "botcraft/AI/BehaviourClient.hpp"
#include "botcraft/AI/BehaviourTree.hpp"
#include "botcraft/Network/NetworkManager.hpp"
#include "botcraft/Utilities/Logger.hpp"
#include "botcraft/Utilities/SleepUtilities.hpp"
#if USE_GUI
#include "botcraft/Renderer/RenderingManager.hpp"
#endif
namespace Botcraft
{
/// @brief The base class you should inherit if you need to
/// implement some custom Handle functions AND need to add
/// custom fields to your derived class. If you just need
/// some custom Handle, inheriting SimpleBehaviourClient is
/// sufficient.
/// @tparam TDerived Any class inheriting this class (see SimpleBehaviourClient)
template<typename TDerived>
class TemplatedBehaviourClient : public BehaviourClient
{
private:
/// @brief Custom internal type used when the tree needs
/// to be changed. It does not inherit std::exception to
/// prevent tree components from catching it
class SwapTree
{
};
/// @brief Custom internal type used when the tree needs
/// to be stopped. It does not inherit std::exception to
/// prevent tree components from catching it
class Interrupted
{
};
public:
TemplatedBehaviourClient(const bool use_renderer_) :
BehaviourClient(use_renderer_)
{
swap_tree = false;
}
virtual ~TemplatedBehaviourClient()
{
// Make sure should_be_closed is set to false
// otherwise the behaviour_thread will not exit
// properly
{
std::lock_guard<std::mutex> behaviour_guard(behaviour_mutex);
should_be_closed = true;
}
behaviour_cond_var.notify_all();
if (behaviour_thread.joinable())
{
behaviour_thread.join();
}
}
/// @brief Save the given tree to replace the current one as soon as possible.
/// @param tree_ The new tree
/// @param blackboard_ Initial values to put into the blackboard when swapping tree
void SetBehaviourTree(const std::shared_ptr<BehaviourTree<TDerived> >& tree_, const std::map<std::string, std::any>& blackboard_ = {})
{
std::lock_guard<std::mutex> behaviour_guard(behaviour_mutex);
swap_tree = true;
new_tree = tree_;
new_blackboard = blackboard_;
}
/// @brief Can be called to pause the execution of the internal
/// tree function. Call it in long function so the behaviour
/// can be interrupted.
virtual void Yield() override
{
std::unique_lock<std::mutex> lock(behaviour_mutex);
behaviour_cond_var.notify_all();
behaviour_cond_var.wait(lock);
if (should_be_closed)
{
throw Interrupted();
}
else if (swap_tree)
{
throw SwapTree();
}
}
/// @brief Start the behaviour thread loop.
void StartBehaviour()
{
tree_loop_ready = false;
behaviour_thread = std::thread(&TemplatedBehaviourClient<TDerived>::TreeLoop, this);
// Wait for the thread to start and ready to run
while (!tree_loop_ready)
{
Utilities::SleepFor(std::chrono::milliseconds(10));
}
}
/// @brief Blocking call, will return only when the client is
/// disconnected from the server.
void RunBehaviourUntilClosed()
{
if (!behaviour_thread.joinable())
{
StartBehaviour();
}
// Main behaviour loop
while (!should_be_closed)
{
std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point end = start + std::chrono::milliseconds(10);
BehaviourStep();
Utilities::SleepUntil(end);
}
}
/// @brief Perform one step of the behaviour tree.
/// Don't forget to call StartBehaviour before.
void BehaviourStep()
{
if (should_be_closed || !network_manager || network_manager->GetConnectionState() != ProtocolCraft::ConnectionState::Play)
{
return;
}
std::unique_lock<std::mutex> lock(behaviour_mutex);
// Resume tree ticking
behaviour_cond_var.notify_all();
// Wait for the next call to Yield()
behaviour_cond_var.wait(lock);
}
/// @brief Set a tree to execute the given action once and block until done.
/// This will change the current tree. BehaviourStep should **NOT** be called
/// by another thread simultaneously. It means you should **NOT** call
/// RunBehaviourUntilClosed when using this sync version.
/// @param timeout_ms Max running time of the function in ms, ignored if 0
/// @param ...args Parameters passed to create tree leaf
template<typename... Args>
void SyncAction(const int timeout_ms, Args&&... args)
{
// Make sure the behaviour thread is running
if (!behaviour_thread.joinable())
{
StartBehaviour();
}
// Set the tree
SetBehaviourTree(Builder<TDerived>()
.sequence()
.succeeder().leaf(std::forward<Args>(args)...)
.leaf([](TDerived& c) { c.SetBehaviourTree(nullptr); return Status::Success; })
.end());
// Perform one step to get out of the Yield lock and swap tree
BehaviourStep();
// Wait for the tree to be set as active one
if (!Utilities::WaitForCondition([&]()
{
return tree != nullptr;
}, 500))
{
LOG_WARNING("Timeout waiting for tree swapping in SyncAction");
return;
}
// Run until tree is ticked once and reset to nullptr
const std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now();
while (tree != nullptr && !should_be_closed)
{
std::chrono::steady_clock::time_point iter_start = std::chrono::steady_clock::now();
std::chrono::steady_clock::time_point iter_end = iter_start + std::chrono::milliseconds(10);
// Timeout, reset tree and get out
if (timeout_ms > 0 && std::chrono::duration_cast<std::chrono::milliseconds>(iter_start - start).count() > timeout_ms)
{
LOG_WARNING("Timeout when doing SyncAction");
SetBehaviourTree(nullptr);
BehaviourStep();
Utilities::WaitForCondition([&]()
{
return tree == nullptr;
}, 500);
break;
}
BehaviourStep();
Utilities::SleepUntil(iter_end);
}
}
/// @brief Set a tree to execute the given action once and block until done.
/// This will change the current tree. BehaviourStep should **NOT** be called
/// by another thread simultaneously. It means you should **NOT** call
/// RunBehaviourUntilClosed when using this sync version. This version has no
/// timeout and will run until the tree ends.
/// @param ...args Parameters passed to create tree leaf
template<typename... Args>
void SyncAction(Args&&... args)
{
return SyncAction(0, std::forward<Args>(args)...);
}
void OnTreeChanged(const BaseNode* root)
{
const std::string& tree_name = root != nullptr ? root->GetName() : "nullptr";
LOG_INFO("Behaviour tree changed" << (tree_name.empty() ? " (anonymous tree)" : (" to " + tree_name)));
#if USE_GUI
if (rendering_manager != nullptr)
{
rendering_manager->SetCurrentBehaviourTree(root);
}
#endif
}
#if USE_GUI
void OnFullTreeStart()
{
if (rendering_manager != nullptr)
{
rendering_manager->ResetBehaviourState();
}
}
void OnNodeStartTick()
{
if (rendering_manager != nullptr)
{
rendering_manager->BehaviourStartTick();
while (rendering_manager->IsBehaviourGUIPaused())
{
Yield();
}
}
}
void OnNodeEndTick(const Status s)
{
if (rendering_manager != nullptr)
{
rendering_manager->BehaviourEndTick(s == Status::Success);
}
}
void OnNodeTickChild(const size_t i)
{
if (rendering_manager != nullptr)
{
rendering_manager->BehaviourTickChild(i);
}
}
#endif
private:
void TreeLoop()
{
Logger::GetInstance().RegisterThread("Behaviour - " + GetNetworkManager()->GetMyName());
tree_loop_ready = true;
while (true)
{
try
{
if (tree)
{
#if USE_GUI
OnFullTreeStart();
#endif
tree->Tick(static_cast<TDerived&>(*this));
}
Yield();
}
// We need to update the tree with the new one
catch (const SwapTree&)
{
tree = new_tree;
new_tree = nullptr;
swap_tree = false;
OnTreeChanged(tree.get());
blackboard.Reset(new_blackboard);
continue;
}
// We need to stop the behaviour thread
catch (const Interrupted&)
{
return;
}
catch (const std::exception& e)
{
LOG_ERROR("Exception caught during tree ticking:\n" << e.what() << "\nStopping behaviour.");
return;
}
catch (...)
{
LOG_ERROR("Unknown exception caught during tree ticking. Stopping behaviour.");
return;
}
}
}
private:
std::shared_ptr<BehaviourTree<TDerived> > tree;
std::shared_ptr<BehaviourTree<TDerived> > new_tree;
std::map<std::string, std::any> new_blackboard;
bool swap_tree;
std::thread behaviour_thread;
std::condition_variable behaviour_cond_var;
std::mutex behaviour_mutex;
std::atomic<bool> tree_loop_ready;
};
} // namespace Botcraft
@@ -0,0 +1,91 @@
#pragma once
#include "botcraft/Game/World/Biome.hpp"
#include "botcraft/Game/World/Blockstate.hpp"
#include "botcraft/Game/Inventory/Item.hpp"
#include <vector>
#include <unordered_map>
namespace Botcraft
{
#if USE_GUI
namespace Renderer
{
class Atlas;
}
#endif
class AssetsManager
{
public:
static AssetsManager& getInstance();
AssetsManager(AssetsManager const&) = delete;
void operator=(AssetsManager const&) = delete;
#if PROTOCOL_VERSION < 347 /* < 1.13 */
const std::unordered_map<int, std::unordered_map<unsigned char, std::unique_ptr<Blockstate> > >& Blockstates() const;
#else
const std::unordered_map<int, std::unique_ptr<Blockstate> >& Blockstates() const;
#endif
const Blockstate* GetBlockstate(const BlockstateId id) const;
/// @brief Get the first blockstate found with a given name
/// @param name Name of the blockstate
/// @return A blockstate matching the given name, or default block if not found
const Blockstate* GetBlockstate(const std::string& name) const;
#if PROTOCOL_VERSION < 358 /* < 1.13 */
const std::unordered_map<unsigned char, std::unique_ptr<Biome> >& Biomes() const;
const Biome* GetBiome(const unsigned char id) const;
#else
const std::unordered_map<int, std::unique_ptr<Biome> >& Biomes() const;
const Biome* GetBiome(const int id) const;
#endif
const std::unordered_map<ItemId, std::unique_ptr<Item> >& Items() const;
const Item* GetItem(const ItemId id) const;
const Item* GetItem(const std::string& item_name) const;
ItemId GetItemID(const std::string& item_name) const;
#if USE_GUI
const Renderer::Atlas* GetAtlas() const;
#endif
private:
AssetsManager();
void LoadBlocksFile();
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
void FlattenBlocks();
#endif
void LoadBiomesFile();
void LoadItemsFile();
#if USE_GUI
void LoadTextures();
#endif
void ClearCaches();
#if USE_GUI
void UpdateModelsWithAtlasData();
#endif
private:
#if PROTOCOL_VERSION < 347 /* < 1.13 */
std::unordered_map<int, std::unordered_map<unsigned char, std::unique_ptr<Blockstate> > > blockstates;
#else
std::unordered_map<int, std::unique_ptr<Blockstate> > blockstates;
std::vector<const Blockstate*> flattened_blockstates;
size_t flattened_blockstates_size;
#endif
#if PROTOCOL_VERSION < 358 /* < 1.13 */
std::unordered_map<unsigned char, std::unique_ptr<Biome> > biomes;
#else
std::unordered_map<int, std::unique_ptr<Biome> > biomes;
#endif
std::unordered_map<ItemId, std::unique_ptr<Item>> items;
#if USE_GUI
std::unique_ptr<Renderer::Atlas> atlas;
#endif
};
} // Botcraft
@@ -0,0 +1,57 @@
#pragma once
#include "protocolCraft/Handler.hpp"
namespace Botcraft
{
class NetworkManager;
/// @brief The base client handling connection with a server.
/// Only processes packets required to maintain the connection.
class ConnectionClient : public ProtocolCraft::Handler
{
public:
ConnectionClient();
virtual ~ConnectionClient();
/// @brief Connect the client to the server at address
/// @param address Address to connect to, as written in minecraft multiplayer window
/// @param login If login is empty, will try to connect with a Microsoft account
/// @param force_microsoft_account If true, then Microsoft auth flow will be used. In this case, login is used as key to cache the credentials
void Connect(const std::string& address, const std::string& login, const bool force_microsoft_account = false);
virtual void Disconnect();
bool GetShouldBeClosed() const;
void SetShouldBeClosed(const bool b);
std::shared_ptr<NetworkManager> GetNetworkManager() const;
/// @brief Send a message in the game chat
/// @param msg The message to send
void SendChatMessage(const std::string& msg);
/// @brief Send a command in the game chat
/// @param command The command to send (with no / at start)
void SendChatCommand(const std::string& command);
/// @brief Ask to respawn when dead
void Respawn();
protected:
virtual void Handle(ProtocolCraft::Message& msg) override;
virtual void Handle(ProtocolCraft::ClientboundLoginDisconnectPacket& msg) override;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
virtual void Handle(ProtocolCraft::ClientboundContainerAckPacket& msg) override;
#endif
virtual void Handle(ProtocolCraft::ClientboundDisconnectPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundPlayerPositionPacket& msg) override;
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
virtual void Handle(ProtocolCraft::ClientboundDisconnectConfigurationPacket& msg) override;
#endif
protected:
std::shared_ptr<NetworkManager> network_manager;
bool should_be_closed;
};
} //Botcraft
@@ -0,0 +1,78 @@
#pragma once
#include <iosfwd>
#include <map>
#include <optional>
#include <string>
namespace Botcraft
{
class EntityAttribute
{
public:
enum class Type : char
{
Unknown = -1,
Armor,
ArmorToughness,
AttackDamage,
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
AttackKnockback,
#endif
AttackSpeed,
FlyingSpeed,
FollowRange,
HorseJumpStrength,
KnockbackResistance,
Luck,
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
MaxAbsorption,
#endif
MaxHealth,
MovementSpeed,
ZombieSpawnReinforcementsChance,
NUM_ENTITY_ATTRIBUTES
};
struct Modifier
{
enum class Operation : char
{
Add = 0,
MultiplyBase = 1,
MultiplyTotal = 2
};
double amount = 0.0;
Operation operation = Operation::Add;
};
EntityAttribute(const Type type_, const double base_value_);
EntityAttribute() = delete;
void SetBaseValue(const double new_value);
void ClearModifiers();
void RemoveModifier(const std::array<unsigned char, 16>& uuid);
void SetModifier(const std::array<unsigned char, 16>& uuid, const Modifier& modifier);
Type GetType() const;
double GetBaseValue() const;
const std::map<std::array<unsigned char, 16>, Modifier>& GetModifiers() const;
double GetValue() const;
std::optional<Modifier> GetModifier(const std::array<unsigned char, 16>& uuid);
static std::string TypeToString(const Type type);
static Type StringToType(const std::string& s);
private:
void UpdateValue() const;
private:
Type type;
double base_value;
mutable double current_value;
mutable bool up_to_date;
std::map<std::array<unsigned char, 16>, Modifier> modifiers;
};
std::ostream& operator<<(std::ostream& os, const EntityAttribute::Type v);
}
@@ -0,0 +1,77 @@
#pragma once
#include <memory>
#include <shared_mutex>
#include <unordered_map>
#include "protocolCraft/Handler.hpp"
#include "botcraft/Utilities/ScopeLockedWrapper.hpp"
namespace Botcraft
{
class Entity;
class LocalPlayer;
class EntityManager : public ProtocolCraft::Handler
{
public:
EntityManager();
std::shared_ptr<LocalPlayer> GetLocalPlayer();
std::shared_ptr<Entity> GetEntity(const int id) const;
void AddEntity(const std::shared_ptr<Entity>& entity);
/// @brief Get a read-only locked version of all the loaded entities (including local player)
/// @return Basically an object you can use as a std::unordered_map<int, std::shared_ptr<Entity>>*.
/// **ALL ENTITIES UPDATE WILL BE BLOCKED WHILE THIS OBJECT IS ALIVE**, make sure it goes out of scope
/// as soon as you don't need it.
Utilities::ScopeLockedWrapper<const std::unordered_map<int, std::shared_ptr<Entity>>, std::shared_mutex, std::shared_lock> GetEntities() const;
protected:
virtual void Handle(ProtocolCraft::ClientboundLoginPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundPlayerPositionPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundAddEntityPacket& msg) override;
#if PROTOCOL_VERSION < 759 /* < 1.19 */
virtual void Handle(ProtocolCraft::ClientboundAddMobPacket& msg) override;
#endif
virtual void Handle(ProtocolCraft::ClientboundAddExperienceOrbPacket& msg) override;
#if PROTOCOL_VERSION < 721 /* < 1.16 */
virtual void Handle(ProtocolCraft::ClientboundAddGlobalEntityPacket& msg) override;
#endif
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
virtual void Handle(ProtocolCraft::ClientboundAddPlayerPacket& msg) override;
#endif
virtual void Handle(ProtocolCraft::ClientboundSetHealthPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundTeleportEntityPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundPlayerAbilitiesPacket& msg) override;
#if PROTOCOL_VERSION < 755 /* < 1.17 */
virtual void Handle(ProtocolCraft::ClientboundMoveEntityPacket& msg) override;
#endif
virtual void Handle(ProtocolCraft::ClientboundMoveEntityPacketPos& msg) override;
virtual void Handle(ProtocolCraft::ClientboundMoveEntityPacketPosRot& msg) override;
virtual void Handle(ProtocolCraft::ClientboundMoveEntityPacketRot& msg) override;
#if PROTOCOL_VERSION == 755 /* 1.17 */
virtual void Handle(ProtocolCraft::ClientboundRemoveEntityPacket& msg) override;
#else
virtual void Handle(ProtocolCraft::ClientboundRemoveEntitiesPacket& msg) override;
#endif
virtual void Handle(ProtocolCraft::ClientboundRespawnPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundGameEventPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundSetEntityDataPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundSetEntityMotionPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundSetEquipmentPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundUpdateAttributesPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundUpdateMobEffectPacket& msg) override;
virtual void Handle(ProtocolCraft::ClientboundRemoveMobEffectPacket& msg) override;
private:
std::unordered_map<int, std::shared_ptr<Entity> > entities;
// The current player is stored independently
std::shared_ptr<LocalPlayer> local_player;
mutable std::shared_mutex entity_manager_mutex;
};
} // Botcraft
@@ -0,0 +1,15 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#pragma once
#include "botcraft/Game/Vector3.hpp"
#include "protocolCraft/Types/Identifier.hpp"
namespace Botcraft
{
struct GlobalPos
{
ProtocolCraft::Identifier dimension;
Position pos;
};
}
#endif
@@ -0,0 +1,145 @@
#pragma once
#include "botcraft/Game/Entities/entities/player/PlayerEntity.hpp"
#include <optional>
namespace Botcraft
{
struct PlayerInputs
{
double forward_axis = 0.0;
double left_axis = 0.0;
bool jump = false;
bool sneak = false;
bool sprint = false;
};
class LocalPlayer : public PlayerEntity
{
friend class PhysicsManager;
public:
LocalPlayer();
virtual ~LocalPlayer();
Vector3<double> GetFrontVector() const;
Vector3<double> GetXZVector() const;
Vector3<double> GetRightVector() const;
GameType GetGameMode() const;
char GetAbilitiesFlags() const;
bool GetInvulnerable() const;
bool GetFlying() const;
bool GetMayFly() const;
/// @brief If true, the player can break any block in no time (creative mode)
/// @return Instabuild ability value
bool GetInstabuild() const;
bool GetMayBuild() const;
float GetFlyingSpeed() const;
float GetWalkingSpeed() const;
float GetHealth() const;
int GetFood() const;
float GetFoodSaturation() const;
bool GetDirtyInputs() const;
bool IsClimbing() const;
bool IsInWater() const;
bool IsInLava() const;
bool IsInFluid() const;
void SetGameMode(const GameType game_mode_);
void SetAbilitiesFlags(const char abilities_flags_);
void SetFlyingSpeed(const float flying_speed_);
void SetWalkingSpeed(const float walking_speed_);
void SetHealth(const float health_);
void SetFood(const int food_);
void SetFoodSaturation(const float food_saturation_);
virtual void SetPosition(const Vector3<double>& pos) override;
virtual void SetX(const double x) override;
virtual void SetY(const double y) override;
virtual void SetZ(const double z) override;
/// @brief Set Yaw angle (horizontal plane orientation)
/// @param yaw_ New yaw, in degree
virtual void SetYaw(const float yaw_) override;
/// @brief Set Pitch angle (look up is -90°, look down is 90°)
/// @param pitch_ New pitch, in degree
virtual void SetPitch(const float pitch_) override;
void SetInputsForward(const double d);
void AddInputsForward(const double d);
void SetInputsLeft(const double d);
void AddInputsLeft(const double d);
void SetInputsJump(const bool b);
void SetInputsSneak(const bool b);
void SetInputsSprint(const bool b);
void SetInputs(const PlayerInputs& inputs_);
virtual bool IsLocalPlayer() const override;
virtual bool IsRemotePlayer() const override;
void LookAt(const Vector3<double>& pos, const bool set_pitch = false);
private:
void UpdateVectors();
void ResetInputs();
void SetAbilitiesFlagsImpl(const char abilities_flags_);
void UpdateAbilitiesFlagsImpl();
#if PROTOCOL_VERSION < 405 /* < 1.14 */
protected:
virtual double GetEyeHeightImpl() const override;
virtual double GetHeightImpl() const override;
#endif
private:
Vector3<double> front_vector;
Vector3<double> xz_vector;
Vector3<double> right_vector;
PlayerInputs inputs;
bool dirty_inputs;
GameType game_mode;
char abilities_flags;
bool invulnerable;
/// @brief Flying in creative/spectator
bool flying;
/// @brief If this player can fly in creative/spectator
bool may_fly;
/// @brief Insta break blocks in creative
bool instabuild;
bool may_build;
float flying_speed;
float walking_speed;
float health;
int food;
float food_saturation;
// Used during physics step (accessible as PhysicsManager is a friend class)
bool in_water;
bool in_lava;
bool under_water;
bool crouching;
bool horizontal_collision;
bool on_climbable;
Vector3<double> stuck_speed_multiplier;
int jump_delay;
int fly_jump_trigger_time;
std::optional<Position> supporting_block_pos;
bool on_ground_without_supporting_block;
bool previous_sprinting;
bool previous_shift_key_down;
Vector3<double> previous_position;
float previous_yaw;
float previous_pitch;
bool previous_on_ground;
bool previous_jump;
bool previous_sneak;
double previous_forward;
};
} // Botcraft
@@ -0,0 +1,13 @@
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#pragma once
namespace Botcraft
{
struct VillagerData
{
int type;
int profession;
int level;
};
}
#endif
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/PathfinderMobEntity.hpp"
namespace Botcraft
{
class AgeableMobEntity : public PathfinderMobEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = PathfinderMobEntity::metadata_count + PathfinderMobEntity::hierarchy_metadata_count;
public:
AgeableMobEntity();
virtual ~AgeableMobEntity();
virtual bool IsAgeableMob() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataBabyId() const;
void SetDataBabyId(const bool data_baby_id);
};
}
@@ -0,0 +1,67 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#include "protocolCraft/Types/Particles/Particle.hpp"
#endif
namespace Botcraft
{
class AreaEffectCloudEntity : public Entity
{
protected:
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
static constexpr int metadata_count = 4;
#else
static constexpr int metadata_count = 6;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
AreaEffectCloudEntity();
virtual ~AreaEffectCloudEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
float GetDataRadius() const;
int GetDataColor() const;
bool GetDataWaiting() const;
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
//TODO: pointed object won't be thread safe
std::shared_ptr<ProtocolCraft::Particle> GetDataParticle() const;
#else
std::optional<int> GetDataParticle() const;
int GetDataParticleArgument1() const;
int GetDataParticleArgument2() const;
#endif
void SetDataRadius(const float data_radius);
void SetDataColor(const int data_color);
void SetDataWaiting(const bool data_waiting);
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
void SetDataParticle(const std::shared_ptr<ProtocolCraft::Particle>& data_particle);
#else
void SetDataParticle(const std::optional<int>& data_particle_type_id);
void SetDataParticleArgument1(const int data_particle_argument1);
void SetDataParticleArgument2(const int data_particle_argument2);
#endif
protected:
float GetDataRadiusImpl() const;
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,42 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/DisplayEntity.hpp"
namespace Botcraft
{
class DisplayBlockDisplayEntity : public DisplayEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = DisplayEntity::metadata_count + DisplayEntity::hierarchy_metadata_count;
public:
DisplayBlockDisplayEntity();
virtual ~DisplayBlockDisplayEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataBlockStateId() const;
void SetDataBlockStateId(const int data_block_state_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,74 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class DisplayEntity : public Entity
{
protected:
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
static constexpr int metadata_count = 14;
#else
static constexpr int metadata_count = 15;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
DisplayEntity();
virtual ~DisplayEntity();
virtual bool IsDisplay() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
int GetDataInterpolationStartDeltaTicksId() const;
int GetDataInterpolationDurationId() const;
#else
int GetDataTransformationInterpolationStartDeltaTicksId() const;
int GetDataTransformationInterpolationDurationId() const;
int GetDataPosRotInterpolationDurationId() const;
#endif
Vector3<float> GetDataTranslationId() const;
Vector3<float> GetDataScaleId() const;
std::array<float, 4> GetDataLeftRotationId() const;
std::array<float, 4> GetDataRightRotationId() const;
char GetDataBillboardRenderConstraintsId() const;
int GetDataBrightnessOverrideId() const;
float GetDataViewRangeId() const;
float GetDataShadowRadiusId() const;
float GetDataShadowStrengthId() const;
float GetDataWidthId() const;
float GetDataHeightId() const;
int GetDataGlowColorOverrideId() const;
#if PROTOCOL_VERSION < 764 /* < 1.20.2 */
void SetDataInterpolationStartDeltaTicksId(const int data_interpolation_start_delta_ticks_id);
void SetDataInterpolationDurationId(const int data_interpolation_duration_id);
#else
void SetDataTransformationInterpolationStartDeltaTicksId(const int data_transformation_interpolation_start_delta_ticks_id);
void SetDataTransformationInterpolationDurationId(const int data_transformation_interpolation_duration_id);
void SetDataPosRotInterpolationDurationId(const int data_pos_rot_interpolation_duration_id);
#endif
void SetDataTranslationId(const Vector3<float> data_translation_id);
void SetDataScaleId(const Vector3<float> data_scale_id);
void SetDataLeftRotationId(const std::array<float, 4> data_left_rotation_id);
void SetDataRightRotationId(const std::array<float, 4> data_right_rotation_id);
void SetDataBillboardRenderConstraintsId(const char data_billboard_render_constraints_id);
void SetDataBrightnessOverrideId(const int data_brightness_override_id);
void SetDataViewRangeId(const float data_view_range_id);
void SetDataShadowRadiusId(const float data_shadow_radius_id);
void SetDataShadowStrengthId(const float data_shadow_strength_id);
void SetDataWidthId(const float data_width_id);
void SetDataHeightId(const float data_height_id);
void SetDataGlowColorOverrideId(const int data_glow_color_override_id);
};
}
#endif
@@ -0,0 +1,45 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/DisplayEntity.hpp"
namespace Botcraft
{
class DisplayItemDisplayEntity : public DisplayEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = DisplayEntity::metadata_count + DisplayEntity::hierarchy_metadata_count;
public:
DisplayItemDisplayEntity();
virtual ~DisplayItemDisplayEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
ProtocolCraft::Slot GetDataItemStackId() const;
char GetDataItemDisplayId() const;
void SetDataItemStackId(const ProtocolCraft::Slot& data_item_stack_id);
void SetDataItemDisplayId(const char data_item_display_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,51 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/DisplayEntity.hpp"
namespace Botcraft
{
class DisplayTextDisplayEntity : public DisplayEntity
{
protected:
static constexpr int metadata_count = 5;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = DisplayEntity::metadata_count + DisplayEntity::hierarchy_metadata_count;
public:
DisplayTextDisplayEntity();
virtual ~DisplayTextDisplayEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
ProtocolCraft::Chat GetDataTextId() const;
int GetDataLineWidthId() const;
int GetDataBackgroundColorId() const;
char GetDataTextOpacityId() const;
char GetDataStyleFlagsId() const;
void SetDataTextId(const ProtocolCraft::Chat& data_text_id);
void SetDataLineWidthId(const int data_line_width_id);
void SetDataBackgroundColorId(const int data_background_color_id);
void SetDataTextOpacityId(const char data_text_opacity_id);
void SetDataStyleFlagsId(const char data_style_flags_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class ExperienceOrbEntity : public Entity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
ExperienceOrbEntity();
virtual ~ExperienceOrbEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/MobEntity.hpp"
namespace Botcraft
{
class FlyingMobEntity : public MobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = MobEntity::metadata_count + MobEntity::hierarchy_metadata_count;
public:
FlyingMobEntity();
virtual ~FlyingMobEntity();
virtual bool IsFlyingMob() const override;
};
}
@@ -0,0 +1,43 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/SquidEntity.hpp"
namespace Botcraft
{
class GlowSquidEntity : public SquidEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = SquidEntity::metadata_count + SquidEntity::hierarchy_metadata_count;
public:
GlowSquidEntity();
virtual ~GlowSquidEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataDarkTicksRemaining() const;
void SetDataDarkTicksRemaining(const int data_dark_ticks_remaining);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,47 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class InteractionEntity : public Entity
{
protected:
static constexpr int metadata_count = 3;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
InteractionEntity();
virtual ~InteractionEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
float GetDataWidthId() const;
float GetDataHeightId() const;
bool GetDataResponseId() const;
void SetDataWidthId(const float data_width_id);
void SetDataHeightId(const float data_height_id);
void SetDataResponseId(const bool data_response_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class LightningBoltEntity : public Entity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
LightningBoltEntity();
virtual ~LightningBoltEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,96 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
#include "botcraft/Game/Entities/EntityAttribute.hpp"
#include <array>
namespace Botcraft
{
class LivingEntity : public Entity
{
protected:
#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
static constexpr int metadata_count = 7;
#elif PROTOCOL_VERSION > 404 /* > 1.13.2 */
static constexpr int metadata_count = 6;
#else
static constexpr int metadata_count = 5;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
LivingEntity();
virtual ~LivingEntity();
virtual bool IsLivingEntity() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataLivingEntityFlags() const;
float GetDataHealthId() const;
int GetDataEffectColorId() const;
bool GetDataEffectAmbienceId() const;
int GetDataArrowCountId() const;
#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
int GetDataStingerCountId() const;
#endif
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
std::optional<Position> GetSleepingPosId() const;
#endif
void SetDataLivingEntityFlags(const char data_living_entity_flags);
void SetDataHealthId(const float data_health_id);
void SetDataEffectColorId(const int data_effect_color_id);
void SetDataEffectAmbienceId(const bool data_effect_ambience_id);
void SetDataArrowCountId(const int data_arrow_count_id);
#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
void SetDataStingerCountId(const int data_stinger_count_id);
#endif
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
void SetSleepingPosId(const std::optional<Position>& sleeping_pos_id);
#endif
// Attribute stuff
std::optional<EntityAttribute> GetAttribute(const EntityAttribute::Type type) const;
void SetAttributeBaseValue(const EntityAttribute::Type type, const double value);
void RemoveAttributeModifier(const EntityAttribute::Type type, const std::array<unsigned char, 16>& uuid);
void SetAttributeModifier(const EntityAttribute::Type type, const std::array<unsigned char, 16>& uuid, const EntityAttribute::Modifier& modifier);
void ClearModifiers(const EntityAttribute::Type type);
void AddAttribute(const EntityAttribute& attribute);
double GetAttributeMaxHealthValue() const;
double GetAttributeKnockbackResistanceValue() const;
double GetAttributeMovementSpeedValue() const;
double GetAttributeArmorValue() const;
double GetAttributeArmorToughnessValue() const;
#if PROTOCOL_VERSION > 763 /* > 1.20.1 */
double GetAttributeMaxAbsorptionValue() const;
#endif
// 87f46a96-686f-4796-b035-22e16ee9e038
static constexpr std::array<unsigned char, 16> speed_modifier_soul_speed_uuid = { 0x87, 0xF4, 0x6A, 0x96, 0x68, 0x6F, 0x47, 0x96, 0xB0, 0x35, 0x22, 0xE1, 0x6E, 0xE9, 0xE0, 0x38 };
// 1eaf83ff-7207-4596-b37a-d7a07b3ec4ce
static constexpr std::array<unsigned char, 16> speed_modifier_powder_snow_uuid = { 0x1E, 0xAF, 0x83, 0xFF, 0x72, 0x7, 0x45, 0x96, 0xB3, 0x7A, 0xD7, 0xA0, 0x7B, 0x3E, 0xC4, 0xCE };
// 662a6b8d-da3e-4c1c-8813-96ea6097278d
static constexpr std::array<unsigned char, 16> speed_modifier_sprinting_uuid = { 0x66, 0x2A, 0x6B, 0x8D, 0xDA, 0x3E, 0x4C, 0x1C, 0x88, 0x13, 0x96, 0xEA, 0x60, 0x97, 0x27, 0x8D };
protected:
double GetAttributeMovementSpeedValueImpl() const;
void RemoveAttributeModifierImpl(const EntityAttribute::Type type, const std::array<unsigned char, 16>& uuid);
void SetAttributeModifierImpl(const EntityAttribute::Type type, const std::array<unsigned char, 16>& uuid, const EntityAttribute::Modifier& modifier);
char GetDataLivingEntityFlagsImpl() const;
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
std::optional<Position> GetSleepingPosIdImpl() const;
#endif
protected:
std::map<EntityAttribute::Type, EntityAttribute> attributes;
};
}
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class MarkerEntity : public Entity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
MarkerEntity();
virtual ~MarkerEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,36 @@
#pragma once
#include "botcraft/Game/Entities/entities/LivingEntity.hpp"
namespace Botcraft
{
class MobEntity : public LivingEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = LivingEntity::metadata_count + LivingEntity::hierarchy_metadata_count;
public:
MobEntity();
virtual ~MobEntity();
virtual bool IsMob() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataMobFlagsId() const;
void SetDataMobFlagsId(const char data_mob_flags_id);
// Attribute stuff
double GetAttributeFollowRangeValue() const;
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
double GetAttributeAttackKnockbackValue() const;
#endif
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/MobEntity.hpp"
namespace Botcraft
{
class PathfinderMobEntity : public MobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = MobEntity::metadata_count + MobEntity::hierarchy_metadata_count;
public:
PathfinderMobEntity();
virtual ~PathfinderMobEntity();
virtual bool IsPathfinderMob() const override;
};
}
@@ -0,0 +1,32 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class TamableAnimalEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
TamableAnimalEntity();
virtual ~TamableAnimalEntity();
virtual bool IsTamableAnimal() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataFlagsId() const;
std::optional<ProtocolCraft::UUID> GetDataOwneruuidId() const;
void SetDataFlagsId(const char data_flags_id);
void SetDataOwneruuidId(const std::optional<ProtocolCraft::UUID>& data_owneruuid_id);
};
}
@@ -0,0 +1,22 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class UnknownEntity : public Entity
{
public:
UnknownEntity();
virtual ~UnknownEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/MobEntity.hpp"
namespace Botcraft
{
class AmbientCreatureEntity : public MobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = MobEntity::metadata_count + MobEntity::hierarchy_metadata_count;
public:
AmbientCreatureEntity();
virtual ~AmbientCreatureEntity();
virtual bool IsAmbientCreature() const override;
};
}
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/ambient/AmbientCreatureEntity.hpp"
namespace Botcraft
{
class BatEntity : public AmbientCreatureEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AmbientCreatureEntity::metadata_count + AmbientCreatureEntity::hierarchy_metadata_count;
public:
BatEntity();
virtual ~BatEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataIdFlags() const;
void SetDataIdFlags(const char data_id_flags);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/WaterAnimalEntity.hpp"
namespace Botcraft
{
class AbstractFishEntity : public WaterAnimalEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = WaterAnimalEntity::metadata_count + WaterAnimalEntity::hierarchy_metadata_count;
public:
AbstractFishEntity();
virtual ~AbstractFishEntity();
virtual bool IsAbstractFish() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetFromBucket() const;
void SetFromBucket(const bool from_bucket);
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/PathfinderMobEntity.hpp"
namespace Botcraft
{
class AbstractGolemEntity : public PathfinderMobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = PathfinderMobEntity::metadata_count + PathfinderMobEntity::hierarchy_metadata_count;
public:
AbstractGolemEntity();
virtual ~AbstractGolemEntity();
virtual bool IsAbstractGolem() const override;
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractFishEntity.hpp"
namespace Botcraft
{
class AbstractSchoolingFishEntity : public AbstractFishEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractFishEntity::metadata_count + AbstractFishEntity::hierarchy_metadata_count;
public:
AbstractSchoolingFishEntity();
virtual ~AbstractSchoolingFishEntity();
virtual bool IsAbstractSchoolingFish() const override;
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/AgeableMobEntity.hpp"
namespace Botcraft
{
class AnimalEntity : public AgeableMobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AgeableMobEntity::metadata_count + AgeableMobEntity::hierarchy_metadata_count;
public:
AnimalEntity();
virtual ~AnimalEntity();
virtual bool IsAnimal() const override;
};
}
@@ -0,0 +1,49 @@
#if PROTOCOL_VERSION > 498 /* > 1.14.4 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class BeeEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
BeeEntity();
virtual ~BeeEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataFlagsId() const;
int GetDataRemainingAngerTime() const;
void SetDataFlagsId(const char data_flags_id);
void SetDataRemainingAngerTime(const int data_remaining_anger_time);
// Attribute stuff
double GetAttributeFlyingSpeedValue() const;
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,52 @@
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#pragma once
#include "botcraft/Game/Entities/entities/TamableAnimalEntity.hpp"
namespace Botcraft
{
class CatEntity : public TamableAnimalEntity
{
protected:
static constexpr int metadata_count = 4;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = TamableAnimalEntity::metadata_count + TamableAnimalEntity::hierarchy_metadata_count;
public:
CatEntity();
virtual ~CatEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataTypeId() const;
bool GetIsLying() const;
bool GetRelaxStateOne() const;
int GetDataCollarColor() const;
void SetDataTypeId(const int data_type_id);
void SetIsLying(const bool is_lying);
void SetRelaxStateOne(const bool relax_state_one);
void SetDataCollarColor(const int data_collar_color);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class ChickenEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
ChickenEntity();
virtual ~ChickenEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractSchoolingFishEntity.hpp"
namespace Botcraft
{
class CodEntity : public AbstractSchoolingFishEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractSchoolingFishEntity::metadata_count + AbstractSchoolingFishEntity::hierarchy_metadata_count;
public:
CodEntity();
virtual ~CodEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class CowEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
CowEntity();
virtual ~CowEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,50 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/WaterAnimalEntity.hpp"
namespace Botcraft
{
class DolphinEntity : public WaterAnimalEntity
{
protected:
static constexpr int metadata_count = 3;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = WaterAnimalEntity::metadata_count + WaterAnimalEntity::hierarchy_metadata_count;
public:
DolphinEntity();
virtual ~DolphinEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
Position GetTreasurePos() const;
bool GetGotFish() const;
int GetMoistnessLevel() const;
void SetTreasurePos(const Position& treasure_pos);
void SetGotFish(const bool got_fish);
void SetMoistnessLevel(const int moistness_level);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,52 @@
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class FoxEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 4;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
FoxEntity();
virtual ~FoxEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataTypeId() const;
char GetDataFlagsId() const;
std::optional<ProtocolCraft::UUID> GetDataTrustedId0() const;
std::optional<ProtocolCraft::UUID> GetDataTrustedId1() const;
void SetDataTypeId(const int data_type_id);
void SetDataFlagsId(const char data_flags_id);
void SetDataTrustedId0(const std::optional<ProtocolCraft::UUID>& data_trusted_id_0);
void SetDataTrustedId1(const std::optional<ProtocolCraft::UUID>& data_trusted_id_1);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,44 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractGolemEntity.hpp"
namespace Botcraft
{
class IronGolemEntity : public AbstractGolemEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractGolemEntity::metadata_count + AbstractGolemEntity::hierarchy_metadata_count;
public:
IronGolemEntity();
virtual ~IronGolemEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataFlagsId() const;
void SetDataFlagsId(const char data_flags_id);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,47 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/CowEntity.hpp"
namespace Botcraft
{
class MushroomCowEntity : public CowEntity
{
protected:
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
#else
static constexpr int metadata_count = 0;
#endif
static constexpr int hierarchy_metadata_count = CowEntity::metadata_count + CowEntity::hierarchy_metadata_count;
public:
MushroomCowEntity();
virtual ~MushroomCowEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
std::string GetDataType() const;
void SetDataType(const std::string& data_type);
#endif
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,58 @@
#pragma once
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
#else
#include "botcraft/Game/Entities/entities/TamableAnimalEntity.hpp"
#endif
namespace Botcraft
{
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
class OcelotEntity : public AnimalEntity
#else
class OcelotEntity : public TamableAnimalEntity
#endif
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
OcelotEntity();
virtual ~OcelotEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
bool GetDataTrusting() const;
void SetDataTrusting(const bool data_trusting);
#else
int GetDataTypeId() const;
void SetDataTypeId(const int data_type_id);
#endif
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,56 @@
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class PandaEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 6;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
PandaEntity();
virtual ~PandaEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetUnhappyCounter() const;
int GetSneezeCounter() const;
int GetEatCounter() const;
char GetMainGeneId() const;
char GetHiddenGeneId() const;
char GetDataIdFlags() const;
void SetUnhappyCounter(const int unhappy_counter);
void SetSneezeCounter(const int sneeze_counter);
void SetEatCounter(const int eat_counter);
void SetMainGeneId(const char main_gene_id);
void SetHiddenGeneId(const char hidden_gene_id);
void SetDataIdFlags(const char data_id_flags);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,44 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/ShoulderRidingEntity.hpp"
namespace Botcraft
{
class ParrotEntity : public ShoulderRidingEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = ShoulderRidingEntity::metadata_count + ShoulderRidingEntity::hierarchy_metadata_count;
public:
ParrotEntity();
virtual ~ParrotEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataVariantId() const;
void SetDataVariantId(const int data_variant_id);
// Attribute stuff
double GetAttributeFlyingSpeedValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,43 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class PigEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
PigEntity();
virtual ~PigEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataSaddleId() const;
int GetDataBoostTime() const;
void SetDataSaddleId(const bool data_saddle_id);
void SetDataBoostTime(const int data_boost_time);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,44 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class PolarBearEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
PolarBearEntity();
virtual ~PolarBearEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataStandingId() const;
void SetDataStandingId(const bool data_standing_id);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,43 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractFishEntity.hpp"
namespace Botcraft
{
class PufferfishEntity : public AbstractFishEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractFishEntity::metadata_count + AbstractFishEntity::hierarchy_metadata_count;
public:
PufferfishEntity();
virtual ~PufferfishEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetPuffState() const;
void SetPuffState(const int puff_state);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class RabbitEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
RabbitEntity();
virtual ~RabbitEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataTypeId() const;
void SetDataTypeId(const int data_type_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractSchoolingFishEntity.hpp"
namespace Botcraft
{
class SalmonEntity : public AbstractSchoolingFishEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractSchoolingFishEntity::metadata_count + AbstractSchoolingFishEntity::hierarchy_metadata_count;
public:
SalmonEntity();
virtual ~SalmonEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class SheepEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
SheepEntity();
virtual ~SheepEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataWoolId() const;
void SetDataWoolId(const char data_wool_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/TamableAnimalEntity.hpp"
namespace Botcraft
{
class ShoulderRidingEntity : public TamableAnimalEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = TamableAnimalEntity::metadata_count + TamableAnimalEntity::hierarchy_metadata_count;
public:
ShoulderRidingEntity();
virtual ~ShoulderRidingEntity();
virtual bool IsShoulderRidingEntity() const override;
};
}
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractGolemEntity.hpp"
namespace Botcraft
{
class SnowGolemEntity : public AbstractGolemEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractGolemEntity::metadata_count + AbstractGolemEntity::hierarchy_metadata_count;
public:
SnowGolemEntity();
virtual ~SnowGolemEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataPumpkinId() const;
void SetDataPumpkinId(const char data_pumpkin_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/WaterAnimalEntity.hpp"
namespace Botcraft
{
class SquidEntity : public WaterAnimalEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = WaterAnimalEntity::metadata_count + WaterAnimalEntity::hierarchy_metadata_count;
public:
SquidEntity();
virtual ~SquidEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,43 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractSchoolingFishEntity.hpp"
namespace Botcraft
{
class TropicalFishEntity : public AbstractSchoolingFishEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractSchoolingFishEntity::metadata_count + AbstractSchoolingFishEntity::hierarchy_metadata_count;
public:
TropicalFishEntity();
virtual ~TropicalFishEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataIdTypeVariant() const;
void SetDataIdTypeVariant(const int data_id_type_variant);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,53 @@
#if PROTOCOL_VERSION > 340 /* > 1.12.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class TurtleEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 6;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
TurtleEntity();
virtual ~TurtleEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
Position GetHomePos() const;
bool GetHasEgg() const;
bool GetLayingEgg() const;
Position GetTravelPos() const;
bool GetGoingHome() const;
bool GetTravelling() const;
void SetHomePos(const Position& home_pos);
void SetHasEgg(const bool has_egg);
void SetLayingEgg(const bool laying_egg);
void SetTravelPos(const Position& travel_pos);
void SetGoingHome(const bool going_home);
void SetTravelling(const bool travelling);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/PathfinderMobEntity.hpp"
namespace Botcraft
{
class WaterAnimalEntity : public PathfinderMobEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = PathfinderMobEntity::metadata_count + PathfinderMobEntity::hierarchy_metadata_count;
public:
WaterAnimalEntity();
virtual ~WaterAnimalEntity();
virtual bool IsWaterAnimal() const override;
};
}
@@ -0,0 +1,65 @@
#pragma once
#include "botcraft/Game/Entities/entities/TamableAnimalEntity.hpp"
namespace Botcraft
{
class WolfEntity : public TamableAnimalEntity
{
protected:
#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
static constexpr int metadata_count = 3;
#elif PROTOCOL_VERSION > 498 /* > 1.14.4 */
static constexpr int metadata_count = 2;
#else
static constexpr int metadata_count = 3;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = TamableAnimalEntity::metadata_count + TamableAnimalEntity::hierarchy_metadata_count;
public:
WolfEntity();
virtual ~WolfEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
#if PROTOCOL_VERSION < 499 /* < 1.15 */
float GetDataHealthId() const;
#endif
bool GetDataInterestedId() const;
int GetDataCollarColor() const;
#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
int GetDataRemainingAngerTime() const;
#endif
#if PROTOCOL_VERSION < 499 /* < 1.15 */
void SetDataHealthId(const float data_health_id);
#endif
void SetDataInterestedId(const bool data_interested_id);
void SetDataCollarColor(const int data_collar_color);
#if PROTOCOL_VERSION > 578 /* > 1.15.2 */
void SetDataRemainingAngerTime(const int data_remaining_anger_time);
#endif
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,54 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#pragma once
#include "botcraft/Game/Entities/entities/PathfinderMobEntity.hpp"
namespace Botcraft
{
class AllayEntity : public PathfinderMobEntity
{
protected:
#if PROTOCOL_VERSION < 760 /* < 1.19.1 */
static constexpr int metadata_count = 0;
#else
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
#endif
static constexpr int hierarchy_metadata_count = PathfinderMobEntity::metadata_count + PathfinderMobEntity::hierarchy_metadata_count;
public:
AllayEntity();
virtual ~AllayEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
#if PROTOCOL_VERSION > 759 /* > 1.19 */
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataDancing() const;
bool GetDataCanDuplicate() const;
void SetDataDancing(const bool data_dancing);
void SetDataCanDuplicate(const bool data_can_duplicate);
#endif
// Attribute stuff
double GetAttributeFlyingSpeedValue() const;
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,50 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class AxolotlEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 3;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
AxolotlEntity();
virtual ~AxolotlEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataVariant() const;
bool GetDataPlayingDead() const;
bool GetFromBucket() const;
void SetDataVariant(const int data_variant);
void SetDataPlayingDead(const bool data_playing_dead);
void SetFromBucket(const bool from_bucket);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,45 @@
#if PROTOCOL_VERSION > 760 /* > 1.19.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp"
namespace Botcraft
{
class CamelEntity : public AbstractHorseEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractHorseEntity::metadata_count + AbstractHorseEntity::hierarchy_metadata_count;
public:
CamelEntity();
virtual ~CamelEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDash() const;
long long int GetLastPoseChangeTick() const;
void SetDash(const bool dash);
void SetLastPoseChangeTick(const long long int last_pose_change_tick);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,48 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class FrogEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
FrogEntity();
virtual ~FrogEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataVariantId() const;
std::optional<int> GetDataTongueTargetId() const;
void SetDataVariantId(const int data_variant_id);
void SetDataTongueTargetId(const std::optional<int>& data_tongue_target_id);
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AbstractFishEntity.hpp"
namespace Botcraft
{
class TadpoleEntity : public AbstractFishEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractFishEntity::metadata_count + AbstractFishEntity::hierarchy_metadata_count;
public:
TadpoleEntity();
virtual ~TadpoleEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,58 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class GoatEntity : public AnimalEntity
{
protected:
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
static constexpr int metadata_count = 3;
#else
static constexpr int metadata_count = 1;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
GoatEntity();
virtual ~GoatEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataIsScreamingGoat() const;
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
bool GetDataHasLeftHorn() const;
bool GetDataHasRightHorn() const;
#endif
void SetDataIsScreamingGoat(const bool data_is_screaming_goat);
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
void SetDataHasLeftHorn(const bool data_has_left_horn);
void SetDataHasRightHorn(const bool data_has_right_horn);
#endif
// Attribute stuff
double GetAttributeAttackDamageValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp"
namespace Botcraft
{
class AbstractChestedHorseEntity : public AbstractHorseEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractHorseEntity::metadata_count + AbstractHorseEntity::hierarchy_metadata_count;
public:
AbstractChestedHorseEntity();
virtual ~AbstractChestedHorseEntity();
virtual bool IsAbstractChestedHorse() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
bool GetDataIdChest() const;
void SetDataIdChest(const bool data_id_chest);
};
}
@@ -0,0 +1,43 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class AbstractHorseEntity : public AnimalEntity
{
protected:
#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
static constexpr int metadata_count = 2;
#else
static constexpr int metadata_count = 1;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
AbstractHorseEntity();
virtual ~AbstractHorseEntity();
virtual bool IsAbstractHorse() const override;
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataIdFlags() const;
#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
std::optional<ProtocolCraft::UUID> GetDataIdOwnerUuid() const;
#endif
void SetDataIdFlags(const char data_id_flags);
#if PROTOCOL_VERSION < 762 /* < 1.19.4 */
void SetDataIdOwnerUuid(const std::optional<ProtocolCraft::UUID>& data_id_owner_uuid);
#endif
// Attribute stuff
double GetAttributeJumpStrengthValue() const;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractChestedHorseEntity.hpp"
namespace Botcraft
{
class DonkeyEntity : public AbstractChestedHorseEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractChestedHorseEntity::metadata_count + AbstractChestedHorseEntity::hierarchy_metadata_count;
public:
DonkeyEntity();
virtual ~DonkeyEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,55 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp"
namespace Botcraft
{
class HorseEntity : public AbstractHorseEntity
{
protected:
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
static constexpr int metadata_count = 1;
#else
static constexpr int metadata_count = 2;
#endif
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractHorseEntity::metadata_count + AbstractHorseEntity::hierarchy_metadata_count;
public:
HorseEntity();
virtual ~HorseEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataIdTypeVariant() const;
#if PROTOCOL_VERSION < 405 /* < 1.14 */
std::optional<int> GetArmorType() const;
#endif
void SetDataIdTypeVariant(const int data_id_type_variant);
#if PROTOCOL_VERSION < 405 /* < 1.14 */
void SetArmorType(const std::optional<int>& armor_type);
#endif
// Attribute stuff
// 556e1665-8b10-40c8-8f9d-cf9b1667f295
static constexpr std::array<unsigned char, 16> armor_modifier_uuid = { 0x55, 0x6E, 0x16, 0x65, 0x8B, 0x10, 0x40, 0xC8, 0x8F, 0x9D, 0xCF, 0x9B, 0x16, 0x67, 0xF2, 0x95 };
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,45 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractChestedHorseEntity.hpp"
namespace Botcraft
{
class LlamaEntity : public AbstractChestedHorseEntity
{
protected:
static constexpr int metadata_count = 3;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AbstractChestedHorseEntity::metadata_count + AbstractChestedHorseEntity::hierarchy_metadata_count;
public:
LlamaEntity();
virtual ~LlamaEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataStrengthId() const;
int GetDataSwagId() const;
int GetDataVariantId() const;
void SetDataStrengthId(const int data_strength_id);
void SetDataSwagId(const int data_swag_id);
void SetDataVariantId(const int data_variant_id);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractChestedHorseEntity.hpp"
namespace Botcraft
{
class MuleEntity : public AbstractChestedHorseEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractChestedHorseEntity::metadata_count + AbstractChestedHorseEntity::hierarchy_metadata_count;
public:
MuleEntity();
virtual ~MuleEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp"
namespace Botcraft
{
class SkeletonHorseEntity : public AbstractHorseEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractHorseEntity::metadata_count + AbstractHorseEntity::hierarchy_metadata_count;
public:
SkeletonHorseEntity();
virtual ~SkeletonHorseEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 404 /* > 1.13.2 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/LlamaEntity.hpp"
namespace Botcraft
{
class TraderLlamaEntity : public LlamaEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = LlamaEntity::metadata_count + LlamaEntity::hierarchy_metadata_count;
public:
TraderLlamaEntity();
virtual ~TraderLlamaEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/animal/horse/AbstractHorseEntity.hpp"
namespace Botcraft
{
class ZombieHorseEntity : public AbstractHorseEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = AbstractHorseEntity::metadata_count + AbstractHorseEntity::hierarchy_metadata_count;
public:
ZombieHorseEntity();
virtual ~ZombieHorseEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,45 @@
#if PROTOCOL_VERSION > 761 /* > 1.19.3 */
#pragma once
#include "botcraft/Game/Entities/entities/animal/AnimalEntity.hpp"
namespace Botcraft
{
class SnifferEntity : public AnimalEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = AnimalEntity::metadata_count + AnimalEntity::hierarchy_metadata_count;
public:
SnifferEntity();
virtual ~SnifferEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataState() const;
int GetDataDropSeedAtTick() const;
void SetDataState(const int data_state);
void SetDataDropSeedAtTick(const int data_drop_seed_at_tick);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,43 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class EndCrystalEntity : public Entity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
EndCrystalEntity();
virtual ~EndCrystalEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
std::optional<Position> GetDataBeamTarget() const;
bool GetDataShowBottom() const;
void SetDataBeamTarget(const std::optional<Position>& data_beam_target);
void SetDataShowBottom(const bool data_show_bottom);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/MobEntity.hpp"
namespace Botcraft
{
class EnderDragonEntity : public MobEntity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = MobEntity::metadata_count + MobEntity::hierarchy_metadata_count;
public:
EnderDragonEntity();
virtual ~EnderDragonEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataPhase() const;
void SetDataPhase(const int data_phase);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,50 @@
#pragma once
#include "botcraft/Game/Entities/entities/monster/MonsterEntity.hpp"
namespace Botcraft
{
class WitherBossEntity : public MonsterEntity
{
protected:
static constexpr int metadata_count = 4;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = MonsterEntity::metadata_count + MonsterEntity::hierarchy_metadata_count;
public:
WitherBossEntity();
virtual ~WitherBossEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataTargetA() const;
int GetDataTargetB() const;
int GetDataTargetC() const;
int GetDataIdInv() const;
void SetDataTargetA(const int data_target_a);
void SetDataTargetB(const int data_target_b);
void SetDataTargetC(const int data_target_c);
void SetDataIdInv(const int data_id_inv);
// Attribute stuff
double GetAttributeFlyingSpeedValue() const;
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,53 @@
#pragma once
#include "botcraft/Game/Entities/entities/LivingEntity.hpp"
namespace Botcraft
{
class ArmorStandEntity : public LivingEntity
{
protected:
static constexpr int metadata_count = 7;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = LivingEntity::metadata_count + LivingEntity::hierarchy_metadata_count;
public:
ArmorStandEntity();
virtual ~ArmorStandEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
char GetDataClientFlags() const;
Vector3<float> GetDataHeadPose() const;
Vector3<float> GetDataBodyPose() const;
Vector3<float> GetDataLeftArmPose() const;
Vector3<float> GetDataRightArmPose() const;
Vector3<float> GetDataLeftLegPose() const;
Vector3<float> GetDataRightLegPose() const;
void SetDataClientFlags(const char data_client_flags);
void SetDataHeadPose(const Vector3<float>& data_head_pose);
void SetDataBodyPose(const Vector3<float>& data_body_pose);
void SetDataLeftArmPose(const Vector3<float>& data_left_arm_pose);
void SetDataRightArmPose(const Vector3<float>& data_right_arm_pose);
void SetDataLeftLegPose(const Vector3<float>& data_left_leg_pose);
void SetDataRightLegPose(const Vector3<float>& data_right_leg_pose);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,32 @@
#if PROTOCOL_VERSION > 754 /* > 1.16.5 */
#pragma once
#include "botcraft/Game/Entities/entities/decoration/ItemFrameEntity.hpp"
namespace Botcraft
{
class GlowItemFrameEntity : public ItemFrameEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = ItemFrameEntity::metadata_count + ItemFrameEntity::hierarchy_metadata_count;
public:
GlowItemFrameEntity();
virtual ~GlowItemFrameEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
#endif
@@ -0,0 +1,19 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class HangingEntity : public Entity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
HangingEntity();
virtual ~HangingEntity();
virtual bool IsHangingEntity() const override;
};
}
@@ -0,0 +1,44 @@
#pragma once
#include "botcraft/Game/Entities/entities/decoration/HangingEntity.hpp"
#include "protocolCraft/Types/Slot.hpp"
namespace Botcraft
{
class ItemFrameEntity : public HangingEntity
{
protected:
static constexpr int metadata_count = 2;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = HangingEntity::metadata_count + HangingEntity::hierarchy_metadata_count;
public:
ItemFrameEntity();
virtual ~ItemFrameEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
ProtocolCraft::Slot GetDataItem() const;
int GetDataRotation() const;
void SetDataItem(const ProtocolCraft::Slot& data_item);
void SetDataRotation(const int data_rotation);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,30 @@
#pragma once
#include "botcraft/Game/Entities/entities/decoration/HangingEntity.hpp"
namespace Botcraft
{
class LeashFenceKnotEntity : public HangingEntity
{
protected:
static constexpr int metadata_count = 0;
static constexpr int hierarchy_metadata_count = HangingEntity::metadata_count + HangingEntity::hierarchy_metadata_count;
public:
LeashFenceKnotEntity();
virtual ~LeashFenceKnotEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,46 @@
#pragma once
#include "botcraft/Game/Entities/entities/decoration/HangingEntity.hpp"
namespace Botcraft
{
class PaintingEntity : public HangingEntity
{
protected:
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
#else
static constexpr int metadata_count = 0;
#endif
static constexpr int hierarchy_metadata_count = HangingEntity::metadata_count + HangingEntity::hierarchy_metadata_count;
public:
PaintingEntity();
virtual ~PaintingEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
#if PROTOCOL_VERSION > 758 /* > 1.18.2 */
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
int GetDataPaintingVariantId() const;
void SetDataPaintingVariantId(const int data_painting_variant_id);
#endif
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}
@@ -0,0 +1,41 @@
#pragma once
#include "botcraft/Game/Entities/entities/Entity.hpp"
namespace Botcraft
{
class FallingBlockEntity : public Entity
{
protected:
static constexpr int metadata_count = 1;
static const std::array<std::string, metadata_count> metadata_names;
static constexpr int hierarchy_metadata_count = Entity::metadata_count + Entity::hierarchy_metadata_count;
public:
FallingBlockEntity();
virtual ~FallingBlockEntity();
// Object related stuff
virtual std::string GetName() const override;
virtual EntityType GetType() const override;
// Static stuff, for easier comparison
static std::string GetClassName();
static EntityType GetClassType();
virtual ProtocolCraft::Json::Value Serialize() const override;
// Metadata stuff
virtual void SetMetadataValue(const int index, const std::any& value) override;
Position GetDataStartPos() const;
void SetDataStartPos(const Position& data_start_pos);
protected:
virtual double GetWidthImpl() const override;
virtual double GetHeightImpl() const override;
};
}

Some files were not shown because too many files have changed in this diff Show More