From 7db4e20fd7ee7cf1c25d5c2c5e9e1b1cf97d4c97 Mon Sep 17 00:00:00 2001 From: Debucquoy Anthony tonitch Date: Tue, 26 Sep 2023 23:54:37 +0200 Subject: adding endermite (#5460) * First Draft of adding endermite * Update src/Mobs/Endermite.h Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com> * Adding Protocols + SpawnEgg TODO: don't forget to put the endermite in core plugin for the summon command * Adding endermite to monster.ini * Adding 5% change of spawning endermite when throwing enderpearl * Spawn endermite at last position instead of Hit Position + .cache to .gitignore * fixup! Spawn endermite at last position instead of Hit Position + .cache to .gitignore * destroy endermite if 2 min, not if name is set * Syntax * Adding Enderman targeting endermite + fixing syntax * Fixing compile error + return error [but crash on enderman spawn] * Fix crash but enderman doesn't target * Enderman targeting endermite finished * checking style because i'm a noob at git... * fixup! checking style because i'm a noob at git... * Added endermite egg meta to docs * Final touches Removed unnecesary imports fixed callback to run only in sight distance and actually check sigtlines * Fixed error after not pulling branch --------- Co-authored-by: x12xx12x <44411062+12xx12@users.noreply.github.com> Co-authored-by: Debucquoy --- src/Mobs/Endermite.cpp | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 src/Mobs/Endermite.cpp (limited to 'src/Mobs/Endermite.cpp') diff --git a/src/Mobs/Endermite.cpp b/src/Mobs/Endermite.cpp new file mode 100644 index 000000000..3a89de98a --- /dev/null +++ b/src/Mobs/Endermite.cpp @@ -0,0 +1,41 @@ + +#include "Globals.h" + +#include "Endermite.h" + +#include "../World.h" +#include "../Chunk.h" +#include "../Blocks/BlockHandler.h" +#include "../Blocks/BlockInfested.h" + + + + + +cEndermite::cEndermite() : + Super("Endermite", mtEndermite, "entity.endermite.hurt", "entity.endermite.death", "entity.endermite.ambient", 0.4f, 0.3f), + m_Timer(0), + m_Lifetime(2 * 1000 * 60) // 2 minutes (2 * 1000 (mili to sec) * 60 (sec to min) * 2 because tick = 0.5 sec) +{ +} + + + + + +void cEndermite::Tick(std::chrono::milliseconds a_Dt, cChunk & a_Chunk) +{ + Super::Tick(a_Dt, a_Chunk); + + // Not destroying the endermite if a name is set + if (m_CustomName.empty()) + { + m_Timer += a_Dt; + // Destroy the endermite after 2 minutes + if (m_Timer > m_Lifetime) + { + Destroy(); + } + + } +} -- cgit v1.2.3