1111#include " ll/api/memory/Memory.h"
1212#include " ll/api/service/Bedrock.h"
1313#include " lse/api/MoreGlobal.h"
14- #include " mc/common/ActorUniqueID.h"
1514#include " mc/deps/core/math/Vec2.h"
1615#include " mc/deps/core/string/HashedString.h"
16+ #include " mc/deps/shared_types/legacy/actor/ActorDamageCause.h"
17+ #include " mc/deps/vanilla_components/StateVectorComponent.h"
18+ #include " mc/entity/components/ActorRotationComponent.h"
19+ #include " mc/entity/components/InsideBlockComponent.h"
1720#include " mc/entity/components/IsOnHotBlockFlagComponent.h"
1821#include " mc/entity/utilities/ActorMobilityUtils.h"
22+ #include " mc/legacy/ActorRuntimeID.h"
23+ #include " mc/legacy/ActorUniqueID.h"
1924#include " mc/nbt/CompoundTag.h"
2025#include " mc/world/SimpleContainer.h"
21- #include " mc/world/actor/ActorDamageCause.h"
2226#include " mc/world/actor/ActorDefinitionIdentifier.h"
2327#include " mc/world/actor/ActorType.h"
28+ #include " mc/world/actor/BuiltInActorComponents.h"
2429#include " mc/world/actor/Mob.h"
2530#include " mc/world/actor/item/ItemActor.h"
2631#include " mc/world/actor/player/Player.h"
32+ #include " mc/world/actor/provider/ActorAttribute.h"
2733#include " mc/world/actor/provider/ActorEquipment.h"
2834#include " mc/world/actor/provider/SynchedActorDataAccess.h"
2935#include " mc/world/attribute/AttributeInstance.h"
36+ #include " mc/world/attribute/AttributeModificationContext.h"
37+ #include " mc/world/attribute/MutableAttributeWithContext.h"
3038#include " mc/world/attribute/SharedAttributes.h"
3139#include " mc/world/effect/EffectDuration.h"
3240#include " mc/world/effect/MobEffectInstance.h"
3341#include " mc/world/level/BlockSource.h"
3442#include " mc/world/level/Spawner.h"
3543#include " mc/world/level/biome/Biome.h"
3644#include " mc/world/level/block/Block.h"
45+ #include " mc/world/level/block/VanillaBlockTypeIds.h"
3746#include " mc/world/level/material/Material.h"
3847#include " mc/world/phys/AABB.h"
3948#include " mc/world/phys/HitResult.h"
@@ -216,7 +225,14 @@ Local<Value> EntityClass::isInsidePortal() {
216225 Actor* entity = get ();
217226 if (!entity) return Local<Value>();
218227
219- return Boolean::newBoolean (entity->isInsidePortal ());
228+ auto component = entity->getEntityContext ().tryGetComponent <InsideBlockComponent>();
229+ if (component) {
230+ auto & fullName = component->mInsideBlock ->getLegacyBlock ().mNameInfo ->mFullName ;
231+ return Boolean::newBoolean (
232+ *fullName == VanillaBlockTypeIds::Portal () || *fullName == VanillaBlockTypeIds::EndPortal ()
233+ );
234+ }
235+ return Boolean::newBoolean (false );
220236 }
221237 CATCH (" Fail in isInsidePortal!" )
222238}
@@ -226,7 +242,9 @@ Local<Value> EntityClass::isTrusting() {
226242 Actor* entity = get ();
227243 if (!entity) return Local<Value>();
228244
229- return Boolean::newBoolean (entity->isTrusting ());
245+ return Boolean::newBoolean (
246+ SynchedActorDataAccess::getActorFlag (entity->getEntityContext (), ActorFlags::Trusting)
247+ );
230248 }
231249 CATCH (" Fail in isTrusting!" )
232250}
@@ -316,7 +334,7 @@ Local<Value> EntityClass::isAngry() {
316334 Actor* entity = get ();
317335 if (!entity) return Local<Value>();
318336
319- return Boolean::newBoolean (entity->isAngry ( ));
337+ return Boolean::newBoolean (SynchedActorDataAccess::getActorFlag ( entity->getEntityContext (), ActorFlags::Angry ));
320338 }
321339 CATCH (" Fail in isAngry!" )
322340}
@@ -336,7 +354,9 @@ Local<Value> EntityClass::isMoving() {
336354 Actor* entity = get ();
337355 if (!entity) return Local<Value>();
338356
339- return Boolean::newBoolean (entity->isMoving ());
357+ return Boolean::newBoolean (
358+ SynchedActorDataAccess::getActorFlag (entity->getEntityContext (), ActorFlags::Moving)
359+ );
340360 }
341361 CATCH (" Fail in isMoving!" )
342362}
@@ -415,7 +435,7 @@ Local<Value> EntityClass::setPosDelta(const Arguments& args) {
415435 delta.y = args[1 ].asNumber ().toFloat ();
416436 delta.z = args[2 ].asNumber ().toFloat ();
417437 }
418- entity->getPosDeltaNonConst () = delta;
438+ entity->mBuiltInComponents -> mStateVectorComponent -> mPosDelta = delta;
419439
420440 return Boolean::newBoolean (true );
421441 }
@@ -457,7 +477,7 @@ Local<Value> EntityClass::getHealth() {
457477 Actor* entity = get ();
458478 if (!entity) return Local<Value>();
459479
460- return Number::newNumber (entity->getHealth ( ));
480+ return Number::newNumber (ActorAttribute::getHealth ( entity->getEntityContext () ));
461481 }
462482 CATCH (" Fail in GetHealth!" )
463483}
@@ -497,7 +517,7 @@ Local<Value> EntityClass::getCanPickupItems() {
497517 Actor* entity = get ();
498518 if (!entity) return Local<Value>();
499519
500- return Boolean::newBoolean (entity->getCanPickupItems () );
520+ return Boolean::newBoolean (entity->mCanPickupItems );
501521 }
502522 CATCH (" Fail in getCanPickupItems!" )
503523}
@@ -569,7 +589,11 @@ Local<Value> EntityClass::getInWall() {
569589 Actor* entity = get ();
570590 if (!entity) return Local<Value>();
571591
572- return Boolean::newBoolean (entity->isInWall ());
592+ // The original Actor::isInWall() was moved to MobSuffocationSystemImpl::isInWall() in 1.21.60.10, but the later
593+ // needs too many parameters.
594+ return Boolean::newBoolean (entity->getDimensionBlockSource ().isInWall (
595+ entity->getAttachPos (SharedTypes::Legacy::ActorLocation::BreathingPoint)
596+ ));
573597 }
574598 CATCH (" Fail in getInWall!" )
575599}
@@ -609,7 +633,8 @@ Local<Value> EntityClass::getDirection() {
609633 Actor* entity = get ();
610634 if (!entity) return Local<Value>();
611635
612- Vec2 vec = entity->getRotation ();
636+ // getRotation()
637+ Vec2 vec = entity->mBuiltInComponents ->mActorRotationComponent ->mRotationDegree ;
613638 return DirectionAngle::newAngle (vec.x , vec.y );
614639 }
615640 CATCH (" Fail in getDirection!" )
@@ -675,7 +700,8 @@ Local<Value> EntityClass::teleport(const Arguments& args) {
675700 return Boolean::newBoolean (false );
676701 }
677702 if (!rotationIsValid) {
678- ang = entity->getRotation ();
703+ // getRotation()
704+ ang = entity->mBuiltInComponents ->mActorRotationComponent ->mRotationDegree ;
679705 }
680706 entity->teleport (pos.getVec3 (), pos.dim , ang);
681707 return Boolean::newBoolean (true );
@@ -969,10 +995,12 @@ Local<Value> EntityClass::hurt(const Arguments& args) {
969995 if (!source) {
970996 return Boolean::newBoolean (false );
971997 }
972- ActorDamageByActorSource damageBySource = ActorDamageByActorSource (*source.value (), (ActorDamageCause)type);
998+ ActorDamageByActorSource damageBySource =
999+ ActorDamageByActorSource (*source.value (), (SharedTypes::Legacy::ActorDamageCause)type);
9731000 return Boolean::newBoolean (entity->_hurt (damageBySource, damage, true , false ));
9741001 }
975- ActorDamageSource damageSource = ActorDamageSource ((ActorDamageCause)type);
1002+ ActorDamageSource damageSource;
1003+ damageSource.mCause = (SharedTypes::Legacy::ActorDamageCause)type;
9761004 return Boolean::newBoolean (entity->_hurt (damageSource, damage, true , false ));
9771005 }
9781006 CATCH (" Fail in hurt!" );
@@ -999,7 +1027,7 @@ Local<Value> EntityClass::setHealth(const Arguments& args) {
9991027 Actor* entity = get ();
10001028 if (!entity) return Local<Value>();
10011029
1002- AttributeInstance* healthAttribute = entity->getMutableAttribute (SharedAttributes::HEALTH ());
1030+ MutableAttributeWithContext healthAttribute = entity->getMutableAttribute (SharedAttributes::HEALTH ());
10031031
10041032 healthAttribute->setCurrentValue (args[0 ].asNumber ().toFloat ());
10051033
0 commit comments