aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/MobEffect.cpp
diff options
context:
space:
mode:
authordaoge <3523206925@qq.com>2026-03-03 03:04:10 +0800
committerGitHub <noreply@github.com>2026-03-03 03:04:10 +0800
commitb3feddfef372618c8a9d7a0abcaf18cfad866c18 (patch)
tree267761c3bb39241ba5c347bfbe2254d06686e287 /Minecraft.World/MobEffect.cpp
parent84c31a2331f7a0ec85b9d438992e244f60e5020f (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/MobEffect.cpp')
-rw-r--r--Minecraft.World/MobEffect.cpp199
1 files changed, 158 insertions, 41 deletions
diff --git a/Minecraft.World/MobEffect.cpp b/Minecraft.World/MobEffect.cpp
index f9687a15..61aee91f 100644
--- a/Minecraft.World/MobEffect.cpp
+++ b/Minecraft.World/MobEffect.cpp
@@ -1,5 +1,9 @@
#include "stdafx.h"
+#include "net.minecraft.world.entity.ai.attributes.h"
#include "net.minecraft.world.entity.player.h"
+#include "net.minecraft.world.entity.monster.h"
+#include "net.minecraft.world.entity.h"
+#include "net.minecraft.world.level.h"
#include "net.minecraft.world.damagesource.h"
#include "net.minecraft.world.food.h"
#include "net.minecraft.world.effect.h"
@@ -7,39 +11,74 @@
MobEffect *MobEffect::effects[NUM_EFFECTS];
-MobEffect *MobEffect::voidEffect = NULL;
-MobEffect *MobEffect::movementSpeed = (new MobEffect(1, false, eMinecraftColour_Effect_MovementSpeed)) ->setDescriptionId(IDS_POTION_MOVESPEED) ->setPostfixDescriptionId(IDS_POTION_MOVESPEED_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Speed); //setIcon(0, 0);
-MobEffect *MobEffect::movementSlowdown = (new MobEffect(2, true, eMinecraftColour_Effect_MovementSlowDown)) ->setDescriptionId(IDS_POTION_MOVESLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_MOVESLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Slowness); //->setIcon(1, 0);
-MobEffect *MobEffect::digSpeed = (new MobEffect(3, false, eMinecraftColour_Effect_DigSpeed)) ->setDescriptionId(IDS_POTION_DIGSPEED) ->setPostfixDescriptionId(IDS_POTION_DIGSPEED_POSTFIX)->setDurationModifier(1.5)->setIcon(MobEffect::e_MobEffectIcon_Haste); //->setIcon(2, 0);
-MobEffect *MobEffect::digSlowdown = (new MobEffect(4, true, eMinecraftColour_Effect_DigSlowdown)) ->setDescriptionId(IDS_POTION_DIGSLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_DIGSLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_MiningFatigue); //->setIcon(3, 0);
-MobEffect *MobEffect::damageBoost = (new MobEffect(5, false, eMinecraftColour_Effect_DamageBoost)) ->setDescriptionId(IDS_POTION_DAMAGEBOOST) ->setPostfixDescriptionId(IDS_POTION_DAMAGEBOOST_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Strength); //->setIcon(4, 0);
-MobEffect *MobEffect::heal = (new InstantenousMobEffect(6, false, eMinecraftColour_Effect_Heal)) ->setDescriptionId(IDS_POTION_HEAL) ->setPostfixDescriptionId(IDS_POTION_HEAL_POSTFIX);
-MobEffect *MobEffect::harm = (new InstantenousMobEffect(7, true, eMinecraftColour_Effect_Harm)) ->setDescriptionId(IDS_POTION_HARM) ->setPostfixDescriptionId(IDS_POTION_HARM_POSTFIX);
-MobEffect *MobEffect::jump = (new MobEffect(8, false, eMinecraftColour_Effect_Jump)) ->setDescriptionId(IDS_POTION_JUMP) ->setPostfixDescriptionId(IDS_POTION_JUMP_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_JumpBoost); //->setIcon(2, 1);
-MobEffect *MobEffect::confusion = (new MobEffect(9, true, eMinecraftColour_Effect_Confusion)) ->setDescriptionId(IDS_POTION_CONFUSION) ->setPostfixDescriptionId(IDS_POTION_CONFUSION_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Nausea); //->setIcon(3, 1);
-MobEffect *MobEffect::regeneration = (new MobEffect(10, false, eMinecraftColour_Effect_Regeneration)) ->setDescriptionId(IDS_POTION_REGENERATION) ->setPostfixDescriptionId(IDS_POTION_REGENERATION_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Regeneration); //->setIcon(7, 0);
-MobEffect *MobEffect::damageResistance = (new MobEffect(11, false, eMinecraftColour_Effect_DamageResistance))->setDescriptionId(IDS_POTION_RESISTANCE) ->setPostfixDescriptionId(IDS_POTION_RESISTANCE_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Resistance); //->setIcon(6, 1);
-MobEffect *MobEffect::fireResistance = (new MobEffect(12, false, eMinecraftColour_Effect_FireResistance)) ->setDescriptionId(IDS_POTION_FIRERESISTANCE) ->setPostfixDescriptionId(IDS_POTION_FIRERESISTANCE_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_FireResistance); //->setIcon(7, 1);
-MobEffect *MobEffect::waterBreathing = (new MobEffect(13, false, eMinecraftColour_Effect_WaterBreathing)) ->setDescriptionId(IDS_POTION_WATERBREATHING) ->setPostfixDescriptionId(IDS_POTION_WATERBREATHING_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_WaterBreathing); //->setIcon(0, 2);
-MobEffect *MobEffect::invisibility = (new MobEffect(14, false, eMinecraftColour_Effect_Invisiblity)) ->setDescriptionId(IDS_POTION_INVISIBILITY) ->setPostfixDescriptionId(IDS_POTION_INVISIBILITY_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Invisiblity); //->setIcon(0, 1);
-MobEffect *MobEffect::blindness = (new MobEffect(15, true, eMinecraftColour_Effect_Blindness)) ->setDescriptionId(IDS_POTION_BLINDNESS) ->setPostfixDescriptionId(IDS_POTION_BLINDNESS_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Blindness); //->setIcon(5, 1);
-MobEffect *MobEffect::nightVision = (new MobEffect(16, false, eMinecraftColour_Effect_NightVision)) ->setDescriptionId(IDS_POTION_NIGHTVISION) ->setPostfixDescriptionId(IDS_POTION_NIGHTVISION_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_NightVision); //->setIcon(4, 1);
-MobEffect *MobEffect::hunger = (new MobEffect(17, true, eMinecraftColour_Effect_Hunger)) ->setDescriptionId(IDS_POTION_HUNGER) ->setPostfixDescriptionId(IDS_POTION_HUNGER_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Hunger); //->setIcon(1, 1);
-MobEffect *MobEffect::weakness = (new MobEffect(18, true, eMinecraftColour_Effect_Weakness)) ->setDescriptionId(IDS_POTION_WEAKNESS) ->setPostfixDescriptionId(IDS_POTION_WEAKNESS_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Weakness); //->setIcon(5, 0);
-MobEffect *MobEffect::poison = (new MobEffect(19, true, eMinecraftColour_Effect_Poison)) ->setDescriptionId(IDS_POTION_POISON) ->setPostfixDescriptionId(IDS_POTION_POISON_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Poison); //->setIcon(6, 0);
-MobEffect *MobEffect::reserved_20 = NULL;
-MobEffect *MobEffect::reserved_21 = NULL;
-MobEffect *MobEffect::reserved_22 = NULL;
-MobEffect *MobEffect::reserved_23 = NULL;
-MobEffect *MobEffect::reserved_24 = NULL;
-MobEffect *MobEffect::reserved_25 = NULL;
-MobEffect *MobEffect::reserved_26 = NULL;
-MobEffect *MobEffect::reserved_27 = NULL;
-MobEffect *MobEffect::reserved_28 = NULL;
-MobEffect *MobEffect::reserved_29 = NULL;
-MobEffect *MobEffect::reserved_30 = NULL;
-MobEffect *MobEffect::reserved_31 = NULL;
-
+MobEffect *MobEffect::voidEffect;
+MobEffect *MobEffect::movementSpeed;
+MobEffect *MobEffect::movementSlowdown;
+MobEffect *MobEffect::digSpeed;
+MobEffect *MobEffect::digSlowdown;
+MobEffect *MobEffect::damageBoost;
+MobEffect *MobEffect::heal;
+MobEffect *MobEffect::harm;
+MobEffect *MobEffect::jump;
+MobEffect *MobEffect::confusion;
+MobEffect *MobEffect::regeneration;
+MobEffect *MobEffect::damageResistance;
+MobEffect *MobEffect::fireResistance;
+MobEffect *MobEffect::waterBreathing;
+MobEffect *MobEffect::invisibility;
+MobEffect *MobEffect::blindness;
+MobEffect *MobEffect::nightVision;
+MobEffect *MobEffect::hunger;
+MobEffect *MobEffect::weakness;
+MobEffect *MobEffect::poison;
+MobEffect *MobEffect::wither;
+MobEffect *MobEffect::healthBoost;
+MobEffect *MobEffect::absorption;
+MobEffect *MobEffect::saturation;
+MobEffect *MobEffect::reserved_24;
+MobEffect *MobEffect::reserved_25;
+MobEffect *MobEffect::reserved_26;
+MobEffect *MobEffect::reserved_27;
+MobEffect *MobEffect::reserved_28;
+MobEffect *MobEffect::reserved_29;
+MobEffect *MobEffect::reserved_30;
+MobEffect *MobEffect::reserved_31;
+
+void MobEffect::staticCtor()
+{
+ voidEffect = NULL;
+ movementSpeed = (new MobEffect(1, false, eMinecraftColour_Effect_MovementSpeed)) ->setDescriptionId(IDS_POTION_MOVESPEED) ->setPostfixDescriptionId(IDS_POTION_MOVESPEED_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Speed)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESPEED, 0.2f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //setIcon(0, 0);
+ movementSlowdown = (new MobEffect(2, true, eMinecraftColour_Effect_MovementSlowDown)) ->setDescriptionId(IDS_POTION_MOVESLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_MOVESLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Slowness)->addAttributeModifier(SharedMonsterAttributes::MOVEMENT_SPEED, eModifierId_POTION_MOVESLOWDOWN, -0.15f, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //->setIcon(1, 0);
+ digSpeed = (new MobEffect(3, false, eMinecraftColour_Effect_DigSpeed)) ->setDescriptionId(IDS_POTION_DIGSPEED) ->setPostfixDescriptionId(IDS_POTION_DIGSPEED_POSTFIX)->setDurationModifier(1.5)->setIcon(MobEffect::e_MobEffectIcon_Haste); //->setIcon(2, 0);
+ digSlowdown = (new MobEffect(4, true, eMinecraftColour_Effect_DigSlowdown)) ->setDescriptionId(IDS_POTION_DIGSLOWDOWN) ->setPostfixDescriptionId(IDS_POTION_DIGSLOWDOWN_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_MiningFatigue); //->setIcon(3, 0);
+ damageBoost = (new AttackDamageMobEffect(5, false, eMinecraftColour_Effect_DamageBoost)) ->setDescriptionId(IDS_POTION_DAMAGEBOOST) ->setPostfixDescriptionId(IDS_POTION_DAMAGEBOOST_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Strength)->addAttributeModifier(SharedMonsterAttributes::ATTACK_DAMAGE, eModifierId_POTION_DAMAGEBOOST, 3, AttributeModifier::OPERATION_MULTIPLY_TOTAL); //->setIcon(4, 0);
+ heal = (new InstantenousMobEffect(6, false, eMinecraftColour_Effect_Heal)) ->setDescriptionId(IDS_POTION_HEAL) ->setPostfixDescriptionId(IDS_POTION_HEAL_POSTFIX);
+ harm = (new InstantenousMobEffect(7, true, eMinecraftColour_Effect_Harm)) ->setDescriptionId(IDS_POTION_HARM) ->setPostfixDescriptionId(IDS_POTION_HARM_POSTFIX);
+ jump = (new MobEffect(8, false, eMinecraftColour_Effect_Jump)) ->setDescriptionId(IDS_POTION_JUMP) ->setPostfixDescriptionId(IDS_POTION_JUMP_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_JumpBoost); //->setIcon(2, 1);
+ confusion = (new MobEffect(9, true, eMinecraftColour_Effect_Confusion)) ->setDescriptionId(IDS_POTION_CONFUSION) ->setPostfixDescriptionId(IDS_POTION_CONFUSION_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Nausea); //->setIcon(3, 1);
+ regeneration = (new MobEffect(10, false, eMinecraftColour_Effect_Regeneration)) ->setDescriptionId(IDS_POTION_REGENERATION) ->setPostfixDescriptionId(IDS_POTION_REGENERATION_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Regeneration); //->setIcon(7, 0);
+ damageResistance = (new MobEffect(11, false, eMinecraftColour_Effect_DamageResistance)) ->setDescriptionId(IDS_POTION_RESISTANCE) ->setPostfixDescriptionId(IDS_POTION_RESISTANCE_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Resistance); //->setIcon(6, 1);
+ fireResistance = (new MobEffect(12, false, eMinecraftColour_Effect_FireResistance)) ->setDescriptionId(IDS_POTION_FIRERESISTANCE) ->setPostfixDescriptionId(IDS_POTION_FIRERESISTANCE_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_FireResistance); //->setIcon(7, 1);
+ waterBreathing = (new MobEffect(13, false, eMinecraftColour_Effect_WaterBreathing)) ->setDescriptionId(IDS_POTION_WATERBREATHING) ->setPostfixDescriptionId(IDS_POTION_WATERBREATHING_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_WaterBreathing); //->setIcon(0, 2);
+ invisibility = (new MobEffect(14, false, eMinecraftColour_Effect_Invisiblity)) ->setDescriptionId(IDS_POTION_INVISIBILITY) ->setPostfixDescriptionId(IDS_POTION_INVISIBILITY_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Invisiblity); //->setIcon(0, 1);
+ blindness = (new MobEffect(15, true, eMinecraftColour_Effect_Blindness)) ->setDescriptionId(IDS_POTION_BLINDNESS) ->setPostfixDescriptionId(IDS_POTION_BLINDNESS_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Blindness); //->setIcon(5, 1);
+ nightVision = (new MobEffect(16, false, eMinecraftColour_Effect_NightVision)) ->setDescriptionId(IDS_POTION_NIGHTVISION) ->setPostfixDescriptionId(IDS_POTION_NIGHTVISION_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_NightVision); //->setIcon(4, 1);
+ hunger = (new MobEffect(17, true, eMinecraftColour_Effect_Hunger)) ->setDescriptionId(IDS_POTION_HUNGER) ->setPostfixDescriptionId(IDS_POTION_HUNGER_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Hunger); //->setIcon(1, 1);
+ weakness = (new AttackDamageMobEffect(18, true, eMinecraftColour_Effect_Weakness)) ->setDescriptionId(IDS_POTION_WEAKNESS) ->setPostfixDescriptionId(IDS_POTION_WEAKNESS_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Weakness)->addAttributeModifier(SharedMonsterAttributes::ATTACK_DAMAGE, eModifierId_POTION_WEAKNESS, 2, AttributeModifier::OPERATION_ADDITION); //->setIcon(5, 0);
+ poison = (new MobEffect(19, true, eMinecraftColour_Effect_Poison)) ->setDescriptionId(IDS_POTION_POISON) ->setPostfixDescriptionId(IDS_POTION_POISON_POSTFIX)->setDurationModifier(.25)->setIcon(MobEffect::e_MobEffectIcon_Poison); //->setIcon(6, 0);
+ wither = (new MobEffect(20, true, eMinecraftColour_Effect_Wither)) ->setDescriptionId(IDS_POTION_WITHER) ->setPostfixDescriptionId(IDS_POTION_WITHER_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Wither)->setDurationModifier(.25);
+ healthBoost = (new HealthBoostMobEffect(21, false, eMinecraftColour_Effect_HealthBoost)) ->setDescriptionId(IDS_POTION_HEALTHBOOST) ->setPostfixDescriptionId(IDS_POTION_HEALTHBOOST_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_HealthBoost)->addAttributeModifier(SharedMonsterAttributes::MAX_HEALTH, eModifierId_POTION_HEALTHBOOST, 4, AttributeModifier::OPERATION_ADDITION);
+ absorption = (new AbsoptionMobEffect(22, false, eMinecraftColour_Effect_Absoprtion)) ->setDescriptionId(IDS_POTION_ABSORPTION) ->setPostfixDescriptionId(IDS_POTION_ABSORPTION_POSTFIX)->setIcon(MobEffect::e_MobEffectIcon_Absorption);
+ saturation = (new InstantenousMobEffect(23, false, eMinecraftColour_Effect_Saturation)) ->setDescriptionId(IDS_POTION_SATURATION) ->setPostfixDescriptionId(IDS_POTION_SATURATION_POSTFIX);
+ reserved_24 = NULL;
+ reserved_25 = NULL;
+ reserved_26 = NULL;
+ reserved_27 = NULL;
+ reserved_28 = NULL;
+ reserved_29 = NULL;
+ reserved_30 = NULL;
+ reserved_31 = NULL;
+}
MobEffect::MobEffect(int id, bool isHarmful, eMinecraftColour color) : id(id), _isHarmful(isHarmful), color(color)
{
@@ -86,9 +125,8 @@ int MobEffect::getId()
* @param mob
* @param amplification
*/
-void MobEffect::applyEffectTick(shared_ptr<Mob> mob, int amplification)
+void MobEffect::applyEffectTick(shared_ptr<LivingEntity> mob, int amplification)
{
-
// Maybe move this to separate class implementations in the future?
if (id == regeneration->id)
{
@@ -104,15 +142,26 @@ void MobEffect::applyEffectTick(shared_ptr<Mob> mob, int amplification)
mob->hurt(DamageSource::magic, 1);
}
}
- else if (id == hunger->id && dynamic_pointer_cast<Player>(mob) != NULL)
+ else if (id == wither->id)
+ {
+ mob->hurt(DamageSource::wither, 1);
+ }
+ else if ( (id == hunger->id) && mob->instanceof(eTYPE_PLAYER) )
{
// every tick, cause the same amount of exhaustion as when removing
// a block, times amplification
dynamic_pointer_cast<Player>(mob)->causeFoodExhaustion(FoodConstants::EXHAUSTION_MINE * (amplification + 1));
}
+ else if ( (id == saturation->id) && mob->instanceof(eTYPE_PLAYER) )
+ {
+ if (!mob->level->isClientSide)
+ {
+ dynamic_pointer_cast<Player>(mob)->getFoodData()->eat(amplification + 1, FoodConstants::FOOD_SATURATION_MAX);
+ }
+ }
else if ((id == heal->id && !mob->isInvertedHealAndHarm()) || (id == harm->id && mob->isInvertedHealAndHarm()))
{
- mob->heal(6 << amplification);
+ mob->heal(max(4 << amplification, 0));
}
else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm()))
{
@@ -120,11 +169,11 @@ void MobEffect::applyEffectTick(shared_ptr<Mob> mob, int amplification)
}
}
-void MobEffect::applyInstantenousEffect(shared_ptr<Mob> source, shared_ptr<Mob> mob, int amplification, double scale)
+void MobEffect::applyInstantenousEffect(shared_ptr<LivingEntity> source, shared_ptr<LivingEntity> mob, int amplification, double scale)
{
if ((id == heal->id && !mob->isInvertedHealAndHarm()) || (id == harm->id && mob->isInvertedHealAndHarm()))
{
- int amount = (int) (scale * (double) (6 << amplification) + .5);
+ int amount = (int) (scale * (double) (4 << amplification) + .5);
mob->heal(amount);
}
else if ((id == harm->id && !mob->isInvertedHealAndHarm()) || (id == heal->id && mob->isInvertedHealAndHarm()))
@@ -162,7 +211,17 @@ bool MobEffect::isDurationEffectTick(int remainingDuration, int amplification)
{
// Maybe move this to separate class implementations in the future?
- if (id == regeneration->id || id == poison->id)
+ if (id == regeneration->id)
+ {
+ // tick intervals are 50, 25, 12, 6..
+ int interval = 50 >> amplification;
+ if (interval > 0)
+ {
+ return (remainingDuration % interval) == 0;
+ }
+ return true;
+ }
+ else if (id == poison->id)
{
// tick intervals are 25, 12, 6..
int interval = 25 >> amplification;
@@ -172,6 +231,15 @@ bool MobEffect::isDurationEffectTick(int remainingDuration, int amplification)
}
return true;
}
+ else if (id == wither->id)
+ {
+ int interval = 40 >> amplification;
+ if (interval > 0)
+ {
+ return (remainingDuration % interval) == 0;
+ }
+ return true;
+ }
else if (id == hunger->id)
{
return true;
@@ -219,6 +287,10 @@ bool MobEffect::isHarmful()
wstring MobEffect::formatDuration(MobEffectInstance *instance)
{
+ if (instance->isNoCounter())
+ {
+ return L"**:**";
+ }
int duration = instance->getDuration();
int seconds = duration / SharedConstants::TICKS_PER_SECOND;
@@ -255,7 +327,7 @@ double MobEffect::getDurationModifier()
MobEffect *MobEffect::setDisabled()
{
- this->_isDisabled = true;
+ _isDisabled = true;
return this;
}
@@ -267,4 +339,49 @@ bool MobEffect::isDisabled()
eMinecraftColour MobEffect::getColor()
{
return color;
+}
+
+MobEffect *MobEffect::addAttributeModifier(Attribute *attribute, eMODIFIER_ID id, double amount, int operation)
+{
+ AttributeModifier *effect = new AttributeModifier(id, amount, operation);
+ attributeModifiers.insert(std::pair<Attribute*,AttributeModifier*>(attribute, effect));
+ return this;
+}
+
+unordered_map<Attribute *, AttributeModifier *> *MobEffect::getAttributeModifiers()
+{
+ return &attributeModifiers;
+}
+
+void MobEffect::removeAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAttributeMap *attributes, int amplifier)
+{
+ for (AUTO_VAR(it, attributeModifiers.begin()); it != attributeModifiers.end(); ++it)
+ {
+ AttributeInstance *attribute = attributes->getInstance(it->first);
+
+ if (attribute != NULL)
+ {
+ attribute->removeModifier(it->second);
+ }
+ }
+}
+
+void MobEffect::addAttributeModifiers(shared_ptr<LivingEntity> entity, BaseAttributeMap *attributes, int amplifier)
+{
+ for (AUTO_VAR(it, attributeModifiers.begin()); it != attributeModifiers.end(); ++it)
+ {
+ AttributeInstance *attribute = attributes->getInstance(it->first);
+
+ if (attribute != NULL)
+ {
+ AttributeModifier *original = it->second;
+ attribute->removeModifier(original);
+ attribute->addModifier(new AttributeModifier(original->getId(), getAttributeModifierValue(amplifier, original), original->getOperation()));
+ }
+ }
+}
+
+double MobEffect::getAttributeModifierValue(int amplifier, AttributeModifier *original)
+{
+ return original->getAmount() * (amplifier + 1);
} \ No newline at end of file