77#include " ll/api/memory/Memory.h"
88#include " ll/api/service/Bedrock.h"
99#include " ll/api/service/GamingStatus.h"
10+ #include " mc/common/Globals.h"
1011#include " mc/deps/core/string/HashedString.h"
1112#include " mc/deps/shared_types/legacy/actor/ActorDamageCause.h"
1213#include " mc/entity/components_json_legacy/NpcComponent.h"
2728#include " mc/world/actor/player/Player.h"
2829#include " mc/world/effect/EffectDuration.h"
2930#include " mc/world/effect/MobEffectInstance.h"
31+ #include " mc/world/events/ActorEventCoordinator.h"
32+ #include " mc/world/events/ProjectileHitEvent.h"
3033#include " mc/world/item/CrossbowItem.h"
3134#include " mc/world/item/ItemInstance.h"
3235#include " mc/world/item/ItemStack.h"
@@ -51,11 +54,12 @@ LL_TYPE_INSTANCE_HOOK(
5154 Vec3 const & direction
5255) {
5356 IF_LISTENED (EVENT_TYPES::onSpawnProjectile) {
54- if (id._getLegacyActorType () != ActorType::Trident) {
57+ static auto & tridentName = EntityCanonicalName (ActorType::Trident);
58+ if (id.mCanonicalName .get () != tridentName) {
5559 if (!CallEvent (
5660 EVENT_TYPES::onSpawnProjectile,
5761 EntityClass::newEntity (spawner),
58- String::newString (id.getCanonicalName ())
62+ String::newString (id.mCanonicalName -> getString ())
5963 )) {
6064 return nullptr ;
6165 }
@@ -179,30 +183,28 @@ LL_TYPE_INSTANCE_HOOK(
179183 origin (owner, res);
180184}
181185
182- LL_TYPE_INSTANCE_HOOK (
183- ProjectileHitBlockHook,
184- HookPriority::Normal,
185- Block,
186- &Block::onProjectileHit,
187- void ,
188- BlockSource& region,
189- BlockPos const & pos,
190- Actor const & projectile
191- ) {
192- IF_LISTENED (EVENT_TYPES::onProjectileHitBlock) {
193- if (pos != BlockPos::ZERO () && !this ->isAir ()) {
194- if (!CallEvent (
195- EVENT_TYPES::onProjectileHitBlock,
196- BlockClass::newBlock (*this , pos, region),
197- EntityClass::newEntity (&const_cast <Actor&>(projectile))
198- )) {
199- return ;
200- }
201- }
202- }
203- IF_LISTENED_END (EVENT_TYPES::onProjectileHitBlock);
204- origin (region, pos, projectile);
205- }
186+ // LL_TYPE_INSTANCE_HOOK(
187+ // ProjectileHitBlockHook,
188+ // HookPriority::Normal,
189+ // ActorEventCoordinator,
190+ // &ActorEventCoordinator::sendEvent,
191+ // CoordinatorResult,
192+ // EventRef<ActorGameplayEvent<CoordinatorResult>> const& event
193+ // ) {
194+ // IF_LISTENED(EVENT_TYPES::onProjectileHitBlock) {
195+ // if (pos != BlockPos::ZERO() && !this->isAir()) {
196+ // if (!CallEvent(
197+ // EVENT_TYPES::onProjectileHitBlock,
198+ // BlockClass::newBlock(*this, pos, region),
199+ // EntityClass::newEntity(&const_cast<Actor&>(projectile))
200+ // )) {
201+ // return CoordinatorResult::Cancel;
202+ // }
203+ // }
204+ // }
205+ // IF_LISTENED_END(EVENT_TYPES::onProjectileHitBlock);
206+ // origin(event);
207+ // }
206208
207209LL_TYPE_INSTANCE_HOOK (
208210 MobHurtHook,
@@ -231,7 +233,7 @@ LL_TYPE_INSTANCE_HOOK(
231233 EntityClass::newEntity (this ),
232234 damageSource ? EntityClass::newEntity (damageSource) : Local<Value>(),
233235 Number::newNumber (damage < 0 .0f ? -damage : damage),
234- Number::newNumber ((int )source.getCause () )
236+ Number::newNumber ((int )source.mCause )
235237 )) {
236238 return false ;
237239 }
@@ -252,7 +254,8 @@ LL_TYPE_INSTANCE_HOOK(
252254 IF_LISTENED (EVENT_TYPES::onMobHurt) {
253255 // Mob is still hurt after hook Mob::$hurtEffects, and all hurt events are handled by this function, but we just
254256 // need magic damage.
255- if (source.getCause () == ActorDamageCause::Magic || source.getCause () == ActorDamageCause::Wither) {
257+ if (source.mCause == SharedTypes::Legacy::ActorDamageCause::Magic
258+ || source.mCause == SharedTypes::Legacy::ActorDamageCause::Wither) {
256259 Actor* damageSource = nullptr ;
257260 if (source.isEntitySource ()) {
258261 if (source.isChildEntitySource ()) {
@@ -267,7 +270,7 @@ LL_TYPE_INSTANCE_HOOK(
267270 EntityClass::newEntity (this ),
268271 damageSource ? EntityClass::newEntity (damageSource) : Local<Value>(),
269272 Number::newNumber (damage < 0 .0f ? -damage : damage),
270- Number::newNumber ((int )source.getCause () )
273+ Number::newNumber ((int )source.mCause )
271274 )) {
272275 return 0 .0f ;
273276 }
@@ -289,9 +292,12 @@ LL_TYPE_INSTANCE_HOOK(
289292 ::std::string const & sceneName
290293) {
291294 IF_LISTENED (EVENT_TYPES::onNpcCmd) {
292- auto action = this ->getActionsContainer ().at (actionIndex);
293- if (std::holds_alternative<npc::CommandAction>(*action)) {
294- auto & commands = std::get<npc::CommandAction>(*action).commands ;
295+ auto & action =
296+ mActionsContainer ->mUnke14f11 .as <std::vector<std::variant<npc::CommandAction, npc::UrlAction>>>().at (
297+ actionIndex
298+ );
299+ if (std::holds_alternative<npc::CommandAction>(action)) {
300+ auto & commands = std::get<npc::CommandAction>(action).commands ;
295301 std::string command;
296302 for (auto & cmd : commands.get ()) {
297303 command += cmd.mUnk879303 .as <std::string>() + " ;" ;
@@ -316,26 +322,26 @@ LL_TYPE_INSTANCE_HOOK(
316322LL_TYPE_INSTANCE_HOOK (
317323 EffectUpdateHook,
318324 HookPriority::Normal,
319- MobEffectInstance ,
320- &MobEffectInstance::updateEffects ,
325+ Actor ,
326+ &Actor::onEffectUpdated ,
321327 void ,
322- ::Actor* mob
328+ MobEffectInstance& effect
323329) {
324330 IF_LISTENED (EVENT_TYPES::onEffectUpdated) {
325- if (mob-> isPlayer ()) {
331+ if (isPlayer ()) {
326332 if (!CallEvent (
327333 EVENT_TYPES::onEffectUpdated,
328- PlayerClass::newPlayer (static_cast <Player*>(mob )),
329- String::newString (getComponentName (). getString ()),
330- Number::newNumber (getAmplifier () ),
331- Number::newNumber (getDuration (). getValueForSerialization () )
334+ PlayerClass::newPlayer (reinterpret_cast <Player*>(this )),
335+ String::newString (MobEffect::mMobEffects ()[effect. mId ]-> mComponentName -> getString ()),
336+ Number::newNumber (effect. mAmplifier ),
337+ Number::newNumber (effect. mDuration -> mValue )
332338 )) {
333339 return ;
334340 }
335341 }
336342 }
337343 IF_LISTENED_END (EVENT_TYPES::onEffectUpdated);
338- origin (mob );
344+ origin (effect );
339345}
340346
341347LL_TYPE_INSTANCE_HOOK (
@@ -371,7 +377,9 @@ void ProjectileCreatedEvent() { ProjectileSpawnHook1::hook(); };
371377void ActorRideEvent () { ActorRideHook::hook (); }
372378void WitherDestroyEvent () { WitherDestroyHook::hook (); }
373379void ProjectileHitEntityEvent () { ProjectileHitEntityHook::hook (); }
374- void ProjectileHitBlockEvent () { ProjectileHitBlockHook::hook (); }
380+ void ProjectileHitBlockEvent () {
381+ // ProjectileHitBlockHook::hook();
382+ }
375383void MobHurtEvent () {
376384 MobHurtHook::hook ();
377385 MobHurtEffectHook::hook ();
0 commit comments