diff --git a/Minecraft.Client/Common/Audio/SoundNames.cpp b/Minecraft.Client/Common/Audio/SoundNames.cpp index c82228e2..7c0dd382 100644 --- a/Minecraft.Client/Common/Audio/SoundNames.cpp +++ b/Minecraft.Client/Common/Audio/SoundNames.cpp @@ -272,7 +272,23 @@ const WCHAR *ConsoleSoundEngine::wchSoundNames[eSoundType_MAX]= L"item.armor.equip_generic6", L"damage.critical", //eSoundType_DAMAGE_CRITICAL, - L"item.elytra.flying" // eSoundType_ITEM_ELYTRA_FLYING + L"item.elytra.flying", // eSoundType_ITEM_ELYTRA_FLYING + + L"mob.guardian.attack_loop", + L"mob.guardian.guardian_death", + L"mob.guardian.guardian_hit", + + L"mob.guardian.flop", + + L"mob.guardian.land_death", + L"mob.guardian.land_hit", + L"mob.guardian.land_idle", + + L"mob.guardian.curse", + L"mob.guardian.elder_death", + L"mob.guardian.elder_hit", + L"mob.guardian.elder_idle" + }; diff --git a/Minecraft.Client/GuardianModel.cpp b/Minecraft.Client/GuardianModel.cpp index 775a76c2..18ef11f9 100644 --- a/Minecraft.Client/GuardianModel.cpp +++ b/Minecraft.Client/GuardianModel.cpp @@ -3,6 +3,7 @@ #include "../Minecraft.World/Mth.h" #include "ModelPart.h" #include "../Minecraft.World/Guardian.h" +#include @@ -70,34 +71,41 @@ void GuardianModel::setupAnim(float time, float r, float bob, float yRot, float float afloat4[] = {-8.0f, -8.0f, -8.0f, -8.0f, 0.0f, 0.0f, 0.0f, 0.0f, 8.0f, 8.0f, 8.0f, 8.0f }; float afloat5[] = { 8.0f, -8.0f, 0.0f, 0.0f,-8.0f,-8.0f, 8.0f, 8.0f, 8.0f, -8.0f, 0.0f, 0.0f }; - // Body orientation + guardianBody->yRot = yRot / (180.0f / (float)PI); guardianBody->xRot = xRot / (180.0f / (float)PI); guardianEye->z = -8.25f; + shared_ptr eyeTarget = nullptr; + if (guardian->hasTargetedEntity()) { - shared_ptr target = guardian->getTargetedEntity(); - if (target) - { - - double d0 = (guardian->y + guardian->getEyeHeight()) - - (target->y + target->getEyeHeight()); - guardianEye->y = (d0 > 0.0) ? 0.0f : 1.0f; + eyeTarget = guardian->getTargetedEntity(); + } - - double dx = target->x - guardian->x; - double dz = target->z - guardian->z; - float targetYaw = (float)(atan2(dz, dx) * 180.0 / PI) - 90.0f; - float diff = Mth::wrapDegrees(targetYaw - guardian->yRot); - float clamped = diff / 45.0f; - if (clamped < -2.0f) clamped = -2.0f; - if (clamped > 2.0f) clamped = 2.0f; - guardianEye->x = clamped; - } + if (eyeTarget == nullptr && EntityRenderDispatcher::instance != nullptr) + { + eyeTarget = EntityRenderDispatcher::instance->cameraEntity; + } + + if (eyeTarget != nullptr) + { + double d0 = (guardian->y + guardian->getEyeHeight()) + - (eyeTarget->y + eyeTarget->getEyeHeight()); + guardianEye->y = (d0 > 0.0) ? 0.0f : 1.0f; + + double dx = eyeTarget->x - guardian->x; + double dz = eyeTarget->z - guardian->z; + float targetYaw = (float)(atan2(dz, dx) * 180.0 / PI) - 90.0f; + float diff = Mth::wrapDegrees(targetYaw - guardian->yRot); + + float clamped = diff / 45.0f; + if (clamped < -2.0f) clamped = -2.0f; + if (clamped > 2.0f) clamped = 2.0f; + guardianEye->x = clamped; } else { @@ -106,6 +114,7 @@ void GuardianModel::setupAnim(float time, float r, float bob, float yRot, float } + float f1 = (1.0f - guardian->getSpikesAnimation(0.0f)) * 0.55f; for (int i = 0; i < 12; ++i) diff --git a/Minecraft.Client/GuardianRenderer.cpp b/Minecraft.Client/GuardianRenderer.cpp index a8f851bf..75a89fc6 100644 --- a/Minecraft.Client/GuardianRenderer.cpp +++ b/Minecraft.Client/GuardianRenderer.cpp @@ -110,8 +110,6 @@ void GuardianRenderer::render(shared_ptr _mob, double x, double y, doubl float time = (float)mob->tickCount + a; float texVOff = -time * 0.2f - floor(-time * 0.1f); float eyeHeight = mob->getEyeHeight(); - if (mob && mob->isElder()) - eyeHeight = mob->bbHeight * 0.5f * 2.35f; double targetX = target->xo + (target->x - target->xo) * a; @@ -138,8 +136,8 @@ void GuardianRenderer::render(shared_ptr _mob, double x, double y, doubl glDisable(GL_LIGHTING); glDisable(GL_CULL_FACE); glEnable(GL_BLEND); - glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glDepthMask(true); + glBlendFunc(GL_SRC_ALPHA, GL_ONE); + glDepthMask(false); glPushMatrix(); glTranslatef((float)x, (float)y + eyeHeight, (float)z); @@ -214,11 +212,22 @@ void GuardianRenderer::render(shared_ptr _mob, double x, double y, doubl glDepthMask(true); glDisable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glEnable(GL_LIGHTING); glEnable(GL_CULL_FACE); glPopMatrix(); } + +void GuardianRenderer::scale(shared_ptr mob, float a) +{ + shared_ptr guardian = dynamic_pointer_cast(mob); + if (guardian && guardian->isElder()) + { + glScalef(2.35f, 2.35f, 2.35f); + } +} + void GuardianRenderer::renderModel(shared_ptr mob, float wp, float ws, float bob, float headRotMinusBodyRot, float headRotx, float scale) { @@ -226,10 +235,11 @@ void GuardianRenderer::renderModel(shared_ptr mob, float wp, float if (guardian && guardian->isElder()) { glPushMatrix(); - - glTranslatef(0.0f, -2.0f, 0.0f); - glScalef(2.35f, 2.35f, 2.35f); + + + LivingEntityRenderer::renderModel(mob, wp, ws, bob, headRotMinusBodyRot, headRotx, scale); + glPopMatrix(); } else diff --git a/Minecraft.Client/GuardianRenderer.h b/Minecraft.Client/GuardianRenderer.h index 3b09d738..cb7fe7c6 100644 --- a/Minecraft.Client/GuardianRenderer.h +++ b/Minecraft.Client/GuardianRenderer.h @@ -20,7 +20,7 @@ private: public: GuardianRenderer(Model *model, float shadow); - + void scale(shared_ptr mob, float a)override; virtual bool shouldRender(shared_ptr mob, float camX, float camY, float camZ) override; diff --git a/Minecraft.Client/LevelRenderer.cpp b/Minecraft.Client/LevelRenderer.cpp index 544662a8..de422457 100644 --- a/Minecraft.Client/LevelRenderer.cpp +++ b/Minecraft.Client/LevelRenderer.cpp @@ -28,6 +28,7 @@ #include "BreakingItemParticle.h" #include "SnowShovelParticle.h" #include "BreakingItemParticle.h" +#include "MobAppearanceParticle.h" #include "HeartParticle.h" #include "HugeExplosionParticle.h" #include "HugeExplosionSeedParticle.h" @@ -822,6 +823,7 @@ void LevelRenderer::renderChunksDirect(int layer, double alpha) #ifdef __PSVITA__ #include + // this is need to sort the chunks by depth typedef struct { @@ -2859,7 +2861,7 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle // 4J - the java code doesn't distance cull these two particle types, we need to implement this behaviour differently as our distance check is // mixed up with other things bool distCull = true; - if ( (eParticleType == eParticleType_hugeexplosion) || (eParticleType == eParticleType_largeexplode) || (eParticleType == eParticleType_dragonbreath) || (eParticleType == eParticleType_wake)) + if ( (eParticleType == eParticleType_hugeexplosion) || (eParticleType == eParticleType_largeexplode) || (eParticleType == eParticleType_dragonbreath) || (eParticleType == eParticleType_wake)||(eParticleType == eParticleType_mobAppearance)) { distCull = false; } @@ -3075,6 +3077,10 @@ shared_ptr LevelRenderer::addParticleInternal(ePARTICLE_TYPE eParticle case eParticleType_barrier: particle = std::make_shared(lev, x, y, z, xa, ya, za); break; + case eParticleType_mobAppearance: + particle = std::make_shared(lev, x, y, z); + break; + default: if( ( eParticleType >= eParticleType_iconcrack_base ) && ( eParticleType <= eParticleType_iconcrack_last ) ) { diff --git a/Minecraft.Client/MobAppearanceParticle.cpp b/Minecraft.Client/MobAppearanceParticle.cpp new file mode 100644 index 00000000..6430da7a --- /dev/null +++ b/Minecraft.Client/MobAppearanceParticle.cpp @@ -0,0 +1,151 @@ +#include "stdafx.h" +#include "MobAppearanceParticle.h" +#include "EntityRenderDispatcher.h" +#include "../Minecraft.World/Guardian.h" +#include "../Minecraft.World/Level.h" + + +MobAppearanceParticle::MobAppearanceParticle(Level* level, double x, double y, double z) + : Particle(level, x, y, z, 0.0, 0.0, 0.0) +{ + this->rCol = 1.0f; + this->gCol = 1.0f; + this->bCol = 1.0f; + + this->xd = 0.0; + this->yd = 0.0; + this->zd = 0.0; + this->gravity = 0.0f; + + this->lifetime = 30; + this->alpha = 0.5; +} + +MobAppearanceParticle::~MobAppearanceParticle() {} + + +int MobAppearanceParticle::getParticleTexture() +{ + return 3; +} + +eINSTANCEOF MobAppearanceParticle::GetType() +{ + + return (eINSTANCEOF)eTYPE_ELDER_GUARDIAN; +} + +void MobAppearanceParticle::tick() +{ + if (guardianEntity == nullptr) + { + auto g = std::make_shared(level); + g->setElderClient(); + guardianEntity = g; + } + Particle::tick(); +} + + +void MobAppearanceParticle::render( + Tesselator* /*t*/, + float partialTicks, + float /*xa*/, + float /*ya*/, + float /*za*/, + float /*xa2*/, + float /*za2*/) +{ + if (guardianEntity == nullptr) + return; + + shared_ptr cameraEntity = EntityRenderDispatcher::instance->cameraEntity; + if (cameraEntity == nullptr) + return; + + + { + double dx = cameraEntity->x - x; + double dy = cameraEntity->y - y; + double dz = cameraEntity->z - z; + if (dx*dx + dy*dy + dz*dz > 4.0 * 4.0) + return; + } + + float progress = ((float)age + partialTicks) / (float)lifetime; + float alpha = 0.05f + 0.5f * sinf(progress * (float)PI); + const float scale = 1.0f / 2.35f; + const float fullBright = 240.0f; + + + double camX = cameraEntity->xOld + (cameraEntity->x - cameraEntity->xOld) * partialTicks; + double camY = cameraEntity->yOld + (cameraEntity->y - cameraEntity->yOld) * partialTicks; + double camZ = cameraEntity->zOld + (cameraEntity->z - cameraEntity->zOld) * partialTicks; + + + float camYaw = cameraEntity->yRotO + (cameraEntity->yRot - cameraEntity->yRotO) * partialTicks; + float camPitch = cameraEntity->xRotO + (cameraEntity->xRot - cameraEntity->xRotO) * partialTicks; + + + double savedXOff = EntityRenderDispatcher::xOff; + double savedYOff = EntityRenderDispatcher::yOff; + double savedZOff = EntityRenderDispatcher::zOff; + + EntityRenderDispatcher::xOff = camX; + EntityRenderDispatcher::yOff = camY; + EntityRenderDispatcher::zOff = camZ; + + glMultiTexCoord2f(GL_TEXTURE1, fullBright, fullBright); + glDepthMask(true); + glEnable(GL_BLEND); + glEnable(GL_DEPTH_TEST); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + + glPushMatrix(); + + + float px = (float)(camX - Particle::xOff); + float py = (float)(camY - Particle::yOff); + float pz = (float)(camZ - Particle::zOff); + glTranslatef(px, py, pz); + + glColor4f(1.0f, 1.0f, 1.0f, alpha); + + + glTranslatef(0.0f, 0.0f, 0.0f); + glRotatef(180.0f - camYaw, 0.0f, 1.0f, 0.0f); + glRotatef(60.0f - 150.0f * progress - camPitch, 1.0f, 0.0f, 0.0f); + glTranslatef(0.0f, -0.4f, -1.5f); + glScalef(scale, scale, scale); + + guardianEntity->yRot = guardianEntity->yRotO = 0.0f; + guardianEntity->xRot = guardianEntity->xRotO = 0.0f; + + + EntityRenderDispatcher::instance->render( + guardianEntity, + 0.0, 0.0, 0.0, + 0.0f, + partialTicks); + + glPopMatrix(); + + EntityRenderDispatcher::xOff = savedXOff; + EntityRenderDispatcher::yOff = savedYOff; + EntityRenderDispatcher::zOff = savedZOff; + + glEnable(GL_DEPTH_TEST); + glDepthMask(true); +} + + +shared_ptr MobAppearanceParticle::Provider::createParticle( + ePARTICLE_TYPE /*type*/, + Level* level, + double x, + double y, + double z, + arrayWithLength /*params*/) +{ + return std::make_shared(level, x, y, z); +} \ No newline at end of file diff --git a/Minecraft.Client/MobAppearanceParticle.h b/Minecraft.Client/MobAppearanceParticle.h new file mode 100644 index 00000000..52d36918 --- /dev/null +++ b/Minecraft.Client/MobAppearanceParticle.h @@ -0,0 +1,42 @@ +#pragma once +#include "Particle.h" +#include "Tesselator.h" +#include "../Minecraft.World/Guardian.h" + + +class MobAppearanceParticle : public Particle +{ +public: + class Provider + { + public: + shared_ptr createParticle( + ePARTICLE_TYPE type, + Level* level, + double x, + double y, + double z, + arrayWithLength params); + }; + + MobAppearanceParticle(Level* level, double x, double y, double z); + virtual ~MobAppearanceParticle(); + + virtual int getParticleTexture() override; + + virtual eINSTANCEOF GetType() override; + + virtual void tick() override; + + virtual void render( + Tesselator* t, + float a, + float xa, + float ya, + float za, + float xa2, + float za2) override; + +private: + shared_ptr guardianEntity; +}; \ No newline at end of file diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/attack_loop.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/attack_loop.ogg new file mode 100644 index 00000000..b070c156 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/attack_loop.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/curse.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/curse.ogg new file mode 100644 index 00000000..557ac3d9 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/curse.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_death.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_death.ogg new file mode 100644 index 00000000..139c836c Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_death.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit1.ogg new file mode 100644 index 00000000..b38ccca5 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit2.ogg new file mode 100644 index 00000000..84a6968f Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit3.ogg new file mode 100644 index 00000000..de18bacc Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit4.ogg new file mode 100644 index 00000000..5aff9102 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_hit4.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle1.ogg new file mode 100644 index 00000000..ddc8acaa Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle2.ogg new file mode 100644 index 00000000..e1d1cfd9 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle3.ogg new file mode 100644 index 00000000..a97f3290 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle4.ogg new file mode 100644 index 00000000..d299ca57 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/elder_idle4.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop1.ogg new file mode 100644 index 00000000..8961fb97 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop2.ogg new file mode 100644 index 00000000..49141eb1 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop3.ogg new file mode 100644 index 00000000..5113ebb4 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop4.ogg new file mode 100644 index 00000000..f4b5d78c Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/flop4.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_death.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_death.ogg new file mode 100644 index 00000000..5610433f Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_death.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit1.ogg new file mode 100644 index 00000000..1eee75a1 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit2.ogg new file mode 100644 index 00000000..8a26539e Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit3.ogg new file mode 100644 index 00000000..d7c4a6b4 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit4.ogg new file mode 100644 index 00000000..393bf95e Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/guardian_hit4.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_death.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_death.ogg new file mode 100644 index 00000000..51835b3c Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_death.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit1.ogg new file mode 100644 index 00000000..1283a8aa Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit2.ogg new file mode 100644 index 00000000..7216d50a Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit3.ogg new file mode 100644 index 00000000..9df9d2ab Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit4.ogg new file mode 100644 index 00000000..08538027 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_hit4.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle1.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle1.ogg new file mode 100644 index 00000000..f0aeda88 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle1.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle2.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle2.ogg new file mode 100644 index 00000000..3576b166 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle2.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle3.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle3.ogg new file mode 100644 index 00000000..8cfbf345 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle3.ogg differ diff --git a/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle4.ogg b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle4.ogg new file mode 100644 index 00000000..ca0906d3 Binary files /dev/null and b/Minecraft.Client/Windows64Media/Sound/Minecraft/mob/guardian/land_idle4.ogg differ diff --git a/Minecraft.Client/cmake/sources/Common.cmake b/Minecraft.Client/cmake/sources/Common.cmake index 32fe2071..454419f9 100644 --- a/Minecraft.Client/cmake/sources/Common.cmake +++ b/Minecraft.Client/cmake/sources/Common.cmake @@ -748,6 +748,8 @@ set(_MINECRAFT_CLIENT_COMMON_NET_MINECRAFT_CLIENT_PARTICLE "${CMAKE_CURRENT_SOURCE_DIR}/WaterDropParticle.h" "${CMAKE_CURRENT_SOURCE_DIR}/ParticleType.h" "${CMAKE_CURRENT_SOURCE_DIR}/ParticleType.cpp" + "${CMAKE_CURRENT_SOURCE_DIR}/MobAppearanceParticle.h" + "${CMAKE_CURRENT_SOURCE_DIR}/MobAppearanceParticle.cpp" ) source_group("net/minecraft/client/particle" FILES ${_MINECRAFT_CLIENT_COMMON_NET_MINECRAFT_CLIENT_PARTICLE}) diff --git a/Minecraft.Server/cmake/sources/Common.cmake b/Minecraft.Server/cmake/sources/Common.cmake index 54438f86..de12229c 100644 --- a/Minecraft.Server/cmake/sources/Common.cmake +++ b/Minecraft.Server/cmake/sources/Common.cmake @@ -4,6 +4,8 @@ get_filename_component(_MS_SRC "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE) set(_MINECRAFT_SERVER_COMMON_ROOT + "${_MS_SRC}/../Minecraft.Client/MobAppearanceParticle.h" + "${_MS_SRC}/../Minecraft.Client/MobAppearanceParticle.cpp" "${_MS_SRC}/../Minecraft.Client/AbstractTexturePack.cpp" "${_MS_SRC}/../Minecraft.Client/AchievementPopup.cpp" "${_MS_SRC}/../Minecraft.Client/AchievementScreen.cpp" diff --git a/Minecraft.World/Guardian.cpp b/Minecraft.World/Guardian.cpp index dd0de42e..59cd023a 100644 --- a/Minecraft.World/Guardian.cpp +++ b/Minecraft.World/Guardian.cpp @@ -202,12 +202,7 @@ float Guardian::getSpikesAnimation(float partialTicks) -int Guardian::getAmbientSound() { return -1; } -int Guardian::getHurtSound() { return -1; } -int Guardian::getDeathSound() { return -1; } -float Guardian::getSoundVolume() { return 1.0f; } -int Guardian::getDeathLoot() { return 0; } -bool Guardian::makeStepSound() { return false; } + void Guardian::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { @@ -261,31 +256,36 @@ void Guardian::serverAiStep() { WaterAnimal::serverAiStep(); - if (isElder() && !level->isClientSide) + if (isElder() && !level->isClientSide) +{ + bool periodicTick = ((tickCount + entityId) % 1200 == 0); + + auto& players = level->players; + for (int i = 0; i < (int)players.size(); i++) { - if (((tickCount + entityId) % 1200 == 0)) + shared_ptr player = players[i]; + if (!player) continue; + if (distanceToSqr(player) >= 2500.0) continue; + if (player->abilities.invulnerable) continue; + + MobEffectInstance* existing = player->getEffect(MobEffect::digSlowdown); + bool noEffect = (existing == nullptr); + bool weakEffect = (existing != nullptr && existing->getAmplifier() < 2); + bool shortEffect= (existing != nullptr && existing->getDuration() < 1200); + + + bool applyNow = noEffect || weakEffect || (periodicTick && shortEffect); + + if (applyNow) { - auto& players = level->players; - for (int i = 0; i < (int)players.size(); i++) - { - shared_ptr player = players[i]; - if (!player) continue; + player->addEffect(new MobEffectInstance(MobEffect::digSlowdown->id, 6000, 2)); - if (distanceToSqr(player) >= 2500.0) - continue; - if (player->abilities.invulnerable) - continue; - - - MobEffectInstance *existing = player->getEffect(MobEffect::digSlowdown); - if (existing == nullptr || existing->getAmplifier() < 2 || existing->getDuration() < 1200) - { - player->addEffect(new MobEffectInstance(MobEffect::digSlowdown->id, 6000, 2)); - } - } + level->broadcastEntityEvent(shared_from_this(), (byte)8); + playCurseSound(); } } +} if (!hasTargetedEntity()) @@ -320,6 +320,7 @@ void Guardian::serverAiStep() if (attackTimer == 1) { level->broadcastEntityEvent(shared_from_this(), 21); + playAttackSound(); } else if (attackTimer >= getAttackDuration()) { @@ -379,6 +380,15 @@ void Guardian::aiStep() updateSize(isElder()); clientSideTailAnimationO = clientSideTailAnimation; + if (!isInWater() && onGround) + { + if (clientSideTouchedGround) + { + playFlopSound(); + clientSideTouchedGround = false; + } + } + if (!isInWater()) { clientSideTailAnimation = 2.0f; @@ -478,4 +488,140 @@ MobGroupData *Guardian::finalizeMobSpawn(MobGroupData *groupData, int extraData) if (extraData == 1) setElder(true); return groupData; +} + +void Guardian::handleEntityEvent(byte eventId) +{ + + if (eventId == 8 && level->isClientSide && isElder()) + { + + shared_ptr localPlayer = level->getNearestPlayer(x, y, z, 64.0); + if (localPlayer != nullptr) + { + level->addParticle( + eParticleType_mobAppearance, + localPlayer->x, + localPlayer->bb->y0, + localPlayer->z, + 0.0, 0.0, 0.0); + } + } + + WaterAnimal::handleEntityEvent(eventId); +} + +int Guardian::getAmbientSound() +{ + if (!isInWater()) + { + if (isElder()) + { + + return eSoundType_MOB_ELDER_GUARDIAN_IDLE; + + } + else + { + + return eSoundType_MOB_GUARDIAN_LAND_IDLE; + + + } + } + return -1; +} + +int Guardian::getHurtSound() +{ + if (!isInWater()) + { + if (isElder()) + { + + return eSoundType_MOB_ELDER_GUARDIAN_HIT; + + + } + else + { + + + return eSoundType_MOB_GUARDIAN_LAND_HIT; + + + } + } + else + { + if (isElder()) + { + + + + return eSoundType_MOB_ELDER_GUARDIAN_HIT; + + } + else + { + + return eSoundType_MOB_GUARDIAN_HIT; + + } + } + +} + +int Guardian::getDeathSound() +{ + if (!isInWater()) + { + if (isElder()) + return eSoundType_MOB_ELDER_GUARDIAN_DEATH; + else + return eSoundType_MOB_GUARDIAN_LAND_DEATH; + } + else + { + if (isElder()) + return eSoundType_MOB_ELDER_GUARDIAN_DEATH; + else + return eSoundType_MOB_GUARDIAN_DEATH; + } +} + +bool Guardian::makeStepSound() +{ + return false; +} + + +void Guardian::playFlopSound() +{ + + level->playSound(x, y, z, eSoundType_MOB_GUARDIAN_FLOP, getSoundVolume(), 1.0f); + +} + + +void Guardian::playAttackSound() +{ + + level->playSound(x, y, z, eSoundType_MOB_GUARDIAN_ATTACK_LOOP, getSoundVolume(), 1.0f); +} + +void Guardian::playCurseSound() +{ + + level->playSound(x, y, z, eSoundType_MOB_ELDER_GUARDIAN_CURSE, getSoundVolume(), 1.0f); +} + +float Guardian::getSoundVolume() +{ + return 1.0f; +} + +int Guardian::getDeathLoot() +{ + return 0; } \ No newline at end of file diff --git a/Minecraft.World/Guardian.h b/Minecraft.World/Guardian.h index b03bf7bd..826ec376 100644 --- a/Minecraft.World/Guardian.h +++ b/Minecraft.World/Guardian.h @@ -36,6 +36,9 @@ protected: virtual float getSoundVolume(); virtual int getDeathLoot(); virtual bool makeStepSound(); + void playFlopSound(); + void playAttackSound(); + void playCurseSound(); virtual void dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel); virtual void serverAiStep(); @@ -66,6 +69,7 @@ public: float getTailAnimation(float partialTicks); float getSpikesAnimation(float partialTicks); float getAttackAnimationScale(float partialTicks); + virtual void handleEntityEvent(byte eventId) override; protected: void lookAt(shared_ptr e, float yMax, float xMax); @@ -76,4 +80,5 @@ private: float tx, ty, tz; int attackTimer; shared_ptr targetedEntity; + }; \ No newline at end of file diff --git a/Minecraft.World/ParticleTypes.h b/Minecraft.World/ParticleTypes.h index 646bfdd8..130d5cdb 100644 --- a/Minecraft.World/ParticleTypes.h +++ b/Minecraft.World/ParticleTypes.h @@ -41,6 +41,7 @@ enum ePARTICLE_TYPE eParticleType_angryVillager, eParticleType_happyVillager, eParticleType_fireworksspark, + eParticleType_mobAppearance, // 4J-JEV: In the java, the particle name was used to sneak parameters in for the Terrain and IconCrack particle constructors. diff --git a/Minecraft.World/SoundTypes.h b/Minecraft.World/SoundTypes.h index 971d4661..a2d1bf4d 100644 --- a/Minecraft.World/SoundTypes.h +++ b/Minecraft.World/SoundTypes.h @@ -263,7 +263,19 @@ enum eSOUND_TYPE eSoundType_DAMAGE_CRITICAL, eSoundType_ITEM_ELYTRA_FLYING, - + + eSoundType_MOB_GUARDIAN_ATTACK_LOOP, + eSoundType_MOB_GUARDIAN_DEATH, + eSoundType_MOB_GUARDIAN_HIT, + eSoundType_MOB_GUARDIAN_FLOP, + eSoundType_MOB_GUARDIAN_LAND_DEATH, + eSoundType_MOB_GUARDIAN_LAND_HIT, + eSoundType_MOB_GUARDIAN_LAND_IDLE, + eSoundType_MOB_ELDER_GUARDIAN_CURSE, + eSoundType_MOB_ELDER_GUARDIAN_DEATH, + eSoundType_MOB_ELDER_GUARDIAN_HIT, + eSoundType_MOB_ELDER_GUARDIAN_IDLE, + eSoundType_MAX };