|
7 | 7 | #include "legacy/api/ItemAPI.h"
|
8 | 8 | #include "legacy/api/PlayerAPI.h"
|
9 | 9 | #include "ll/api/service/Bedrock.h"
|
| 10 | +#include "mc/entity/utilities/ActorDamageCause.h" |
10 | 11 | #include "mc/server/ServerPlayer.h"
|
11 | 12 | #include "mc/server/commands/CommandOrigin.h"
|
12 | 13 | #include "mc/server/commands/CommandOriginType.h"
|
@@ -1152,34 +1153,34 @@ LL_TYPE_INSTANCE_HOOK(
|
1152 | 1153 | MobHurtEffectHook,
|
1153 | 1154 | HookPriority::Normal,
|
1154 | 1155 | Mob,
|
1155 |
| - "?hurtEffects@Mob@@UEAAXAEBVActorDamageSource@@M_N1@Z", |
1156 |
| - bool, |
| 1156 | + &Mob::getDamageAfterResistanceEffect, |
| 1157 | + float, |
1157 | 1158 | ActorDamageSource const& source,
|
1158 |
| - float damage, |
1159 |
| - bool knock, |
1160 |
| - bool ignite |
| 1159 | + float damage |
1161 | 1160 | ) {
|
1162 | 1161 | IF_LISTENED(EVENT_TYPES::onMobHurt) {
|
1163 |
| - Actor* damageSource; |
1164 |
| - if (source.isEntitySource()) { |
1165 |
| - if (source.isChildEntitySource()) { |
1166 |
| - damageSource = ll::service::getLevel()->fetchEntity(source.getEntityUniqueID()); |
1167 |
| - } else { |
1168 |
| - damageSource = ll::service::getLevel()->fetchEntity(source.getDamagingEntityUniqueID()); |
| 1162 | + if (source.getCause() == ActorDamageCause::Magic || source.getCause() == ActorDamageCause::Wither) { |
| 1163 | + Actor* damageSource; |
| 1164 | + if (source.isEntitySource()) { |
| 1165 | + if (source.isChildEntitySource()) { |
| 1166 | + damageSource = ll::service::getLevel()->fetchEntity(source.getEntityUniqueID()); |
| 1167 | + } else { |
| 1168 | + damageSource = ll::service::getLevel()->fetchEntity(source.getDamagingEntityUniqueID()); |
| 1169 | + } |
1169 | 1170 | }
|
1170 |
| - } |
1171 | 1171 |
|
1172 |
| - CallEventRtnValue( |
1173 |
| - EVENT_TYPES::onMobHurt, |
1174 |
| - false, |
1175 |
| - EntityClass::newEntity(this), |
1176 |
| - damageSource ? EntityClass::newEntity(damageSource) : Local<Value>(), |
1177 |
| - Number::newNumber(damage), |
1178 |
| - Number::newNumber((int)source.getCause()) |
1179 |
| - ); |
| 1172 | + CallEventRtnValue( |
| 1173 | + EVENT_TYPES::onMobHurt, |
| 1174 | + 0.0f, |
| 1175 | + EntityClass::newEntity(this), |
| 1176 | + damageSource ? EntityClass::newEntity(damageSource) : Local<Value>(), |
| 1177 | + Number::newNumber(damage < 0.0f ? -damage : damage), |
| 1178 | + Number::newNumber((int)source.getCause()) |
| 1179 | + ); |
| 1180 | + } |
1180 | 1181 | }
|
1181 | 1182 | IF_LISTENED_END(EVENT_TYPES::onMobHurt)
|
1182 |
| - return origin(source, damage, knock, ignite); |
| 1183 | + return origin(source, damage); |
1183 | 1184 | }
|
1184 | 1185 |
|
1185 | 1186 | void PlayerStartDestroyBlock() { PlayerStartDestroyHook::hook(); }
|
|
0 commit comments