diff options
| author | daoge <3523206925@qq.com> | 2026-03-03 03:04:10 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2026-03-03 03:04:10 +0800 |
| commit | b3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch) | |
| tree | 267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/MobEffectInstance.cpp | |
| parent | 84c31a2331f7a0ec85b9d438992e244f60e5020f (diff) | |
feat: TU19 (Dec 2014) Features & Content (#155)
* try to resolve merge conflict
* feat: TU19 (Dec 2014) Features & Content (#32)
* December 2014 files
* Working release build
* Fix compilation issues
* Add sound to Windows64Media
* Add DLC content and force Tutorial DLC
* Revert "Add DLC content and force Tutorial DLC"
This reverts commit 97a43994725008e35fceb984d5549df9c8cea470.
* Disable broken light packing
* Disable breakpoint during DLC texture map load
Allows DLC loading but the DLC textures are still broken
* Fix post build not working
* ...
* fix vs2022 build
* fix cmake build
---------
Co-authored-by: Loki <lokirautio@gmail.com>
Diffstat (limited to 'Minecraft.World/MobEffectInstance.cpp')
| -rw-r--r-- | Minecraft.World/MobEffectInstance.cpp | 80 |
1 files changed, 70 insertions, 10 deletions
diff --git a/Minecraft.World/MobEffectInstance.cpp b/Minecraft.World/MobEffectInstance.cpp index 1e15e58c..2ca696f6 100644 --- a/Minecraft.World/MobEffectInstance.cpp +++ b/Minecraft.World/MobEffectInstance.cpp @@ -6,6 +6,10 @@ void MobEffectInstance::_init(int id, int duration, int amplifier) this->id = id; this->duration = duration; this->amplifier = amplifier; + + splash = false; + ambient = false; + noCounter = false; } MobEffectInstance::MobEffectInstance(int id) @@ -23,27 +27,40 @@ MobEffectInstance::MobEffectInstance(int id, int duration, int amplifier) _init(id,duration,amplifier); } +MobEffectInstance::MobEffectInstance(int id, int duration, int amplifier, bool ambient) +{ + _init(id,duration,amplifier); + this->ambient = ambient; +} + MobEffectInstance::MobEffectInstance(MobEffectInstance *copy) { this->id = copy->id; this->duration = copy->duration; this->amplifier = copy->amplifier; + this->splash = copy->splash; + this->ambient = copy->ambient; + this->noCounter = copy->noCounter; } void MobEffectInstance::update(MobEffectInstance *takeOver) { - if (this->id != takeOver->id) + if (id != takeOver->id) { app.DebugPrintf("This method should only be called for matching effects!"); } - if (takeOver->amplifier > this->amplifier) + if (takeOver->amplifier > amplifier) { - this->amplifier = takeOver->amplifier; - this->duration = takeOver->duration; + amplifier = takeOver->amplifier; + duration = takeOver->duration; } - else if (takeOver->amplifier == this->amplifier && this->duration < takeOver->duration) + else if (takeOver->amplifier == amplifier && duration < takeOver->duration) { - this->duration = takeOver->duration; + duration = takeOver->duration; + } + else if (!takeOver->ambient && ambient) + { + ambient = takeOver->ambient; } } @@ -62,13 +79,28 @@ int MobEffectInstance::getAmplifier() return amplifier; } +bool MobEffectInstance::isSplash() +{ + return splash; +} + +void MobEffectInstance::setSplash(bool splash) +{ + this->splash = splash; +} + +bool MobEffectInstance::isAmbient() +{ + return ambient; +} + /** * Runs the effect on a Mob target. * * @param target * @return True if the effect is still active. */ -bool MobEffectInstance::tick(shared_ptr<Mob> target) +bool MobEffectInstance::tick(shared_ptr<LivingEntity> target) { if (duration > 0) { @@ -86,7 +118,7 @@ int MobEffectInstance::tickDownDuration() return --duration; } -void MobEffectInstance::applyEffect(shared_ptr<Mob> mob) +void MobEffectInstance::applyEffect(shared_ptr<LivingEntity> mob) { if (duration > 0) { @@ -133,7 +165,35 @@ wstring MobEffectInstance::toString() } // Was bool equals(Object obj) -bool MobEffectInstance::equals(MobEffectInstance *obj) +bool MobEffectInstance::equals(MobEffectInstance *instance) +{ + return id == instance->id && amplifier == instance->amplifier && duration == instance->duration && splash == instance->splash && ambient == instance->ambient; +} + +CompoundTag *MobEffectInstance::save(CompoundTag *tag) +{ + tag->putByte(L"Id", (byte) getId()); + tag->putByte(L"Amplifier", (byte) getAmplifier()); + tag->putInt(L"Duration", getDuration()); + tag->putBoolean(L"Ambient", isAmbient()); + return tag; +} + +MobEffectInstance *MobEffectInstance::load(CompoundTag *tag) +{ + int id = tag->getByte(L"Id"); + int amplifier = tag->getByte(L"Amplifier"); + int duration = tag->getInt(L"Duration"); + boolean ambient = tag->getBoolean(L"Ambient"); + return new MobEffectInstance(id, duration, amplifier, ambient); +} + +void MobEffectInstance::setNoCounter(bool noCounter) +{ + this->noCounter = noCounter; +} + +bool MobEffectInstance::isNoCounter() { - return this->id == obj->id && this->amplifier == obj->amplifier && this->duration == obj->duration; + return noCounter; }
\ No newline at end of file |
