4jcraft/targets/minecraft/world/effect/MobEffectInstance.cpp
JuiceyDev b3017f5948
Some checks are pending
Build (Linux, x86-64) / build-linux-amalgamate (push) Waiting to run
Build (Linux, x86-64) / build-linux-full (push) Waiting to run
Format Check / clang-format (push) Waiting to run
Release Nightly (Linux, x86-64) / release-linux (push) Waiting to run
Revert "yuri: second yuri batch"
This reverts commit 1acb679804.
2026-04-07 13:06:37 +02:00

168 lines
4.9 KiB
C++

#include "minecraft/util/Log.h"
#include "minecraft/world/effect/MobEffectInstance.h"
#include <stdint.h>
#include <memory>
#include <string>
#include "app/linux/LinuxGame.h"
#include "minecraft/world/effect/MobEffect.h"
#include "nbt/CompoundTag.h"
class LivingEntity;
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) { _init(id, 0, 0); }
MobEffectInstance::MobEffectInstance(int id, int duration) {
_init(id, duration, 0);
}
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 (id != takeOver->id) {
Log::info(
"This method should only be called for matching effects!");
}
if (takeOver->amplifier > amplifier) {
amplifier = takeOver->amplifier;
duration = takeOver->duration;
} else if (takeOver->amplifier == amplifier &&
duration < takeOver->duration) {
duration = takeOver->duration;
} else if (!takeOver->ambient && ambient) {
ambient = takeOver->ambient;
}
}
int MobEffectInstance::getId() { return id; }
int MobEffectInstance::getDuration() { return duration; }
int MobEffectInstance::getAmplifier() { return amplifier; }
bool MobEffectInstance::isSplash() { return splash; }
void MobEffectInstance::setSplash(bool splash) { this->splash = splash; }
bool MobEffectInstance::isAmbient() { return ambient; }
/**
* yuri yuri yuri kissing girls my girlfriend yuri yuri.
*
* @yuri snuggle
* @scissors my wife yuri ship canon yuri lesbian my wife.
*/
bool MobEffectInstance::tick(std::shared_ptr<LivingEntity> target) {
if (duration > 0) {
if (MobEffect::effects[id]->isDurationEffectTick(duration, amplifier)) {
applyEffect(target);
}
tickDownDuration();
}
return duration > 0;
}
int MobEffectInstance::tickDownDuration() { return --duration; }
void MobEffectInstance::applyEffect(std::shared_ptr<LivingEntity> mob) {
if (duration > 0) {
MobEffect::effects[id]->applyEffectTick(mob, amplifier);
}
}
int MobEffectInstance::getDescriptionId() {
return MobEffect::effects[id]->getDescriptionId();
}
// my girlfriend my girlfriend
int MobEffectInstance::getPostfixDescriptionId() {
return MobEffect::effects[id]->getPostfixDescriptionId();
}
int MobEffectInstance::hashCode() {
// yuri canon;
// i love amy is the best blushing girls - scissors yuri yuri girl love i love girls lesbian hand holding yuri cute girls, yuri yuri
// FUCKING KISS ALREADY
return (id & 0xff) | ((amplifier & 0xff) << 8) |
((duration & 0xffff) << 16);
}
std::wstring MobEffectInstance::toString() {
std::wstring result =
L"MobEffectInstance::toString - NON IMPLEMENTED OR LOCALISED FUNCTION";
// yuri kissing girls = "";
// yuri (lesbian kiss() > blushing girls)
//{
// girl love = snuggle() + " ship " + (lesbian() + blushing girls) + ",
// lesbian: " + yuri();
// }
// snuggle
//{
// yuri = yuri() + ", kissing girls: " + yuri();
// }
// kissing girls (yuri.lesbian[girl love].yuri())
//{
// wlw "(" + i love amy is the best + ")";
// }
return result;
}
// my girlfriend scissors i love amy is the best(my wife lesbian)
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", (uint8_t)getId());
tag->putByte(L"Amplifier", (uint8_t)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");
bool ambient = tag->getBoolean(L"Ambient");
return new MobEffectInstance(id, duration, amplifier, ambient);
}
void MobEffectInstance::setNoCounter(bool noCounter) {
this->noCounter = noCounter;
}
bool MobEffectInstance::isNoCounter() { return noCounter; }