Skip to content

Commit 3011f18

Browse files
committed
fix: fix setAbility
1 parent 0688e41 commit 3011f18

File tree

1 file changed

+1
-27
lines changed

1 file changed

+1
-27
lines changed

src/legacy/api/PlayerAPI.cpp

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3516,33 +3516,7 @@ Local<Value> PlayerClass::setAbility(const Arguments& args) {
35163516
try {
35173517
Player* player = get();
35183518
if (!player) return Local<Value>();
3519-
bool value = args[1].asBoolean().value();
3520-
AbilitiesIndex index = AbilitiesIndex(args[0].asNumber().toInt32());
3521-
ActorUniqueID uid = player->getOrCreateUniqueID();
3522-
auto& abilities = player->getAbilities();
3523-
bool flying = abilities.getAbility(AbilitiesIndex::Flying).getBool();
3524-
if (index == AbilitiesIndex::Flying && value && player->isOnGround()) {
3525-
abilities.setAbility(AbilitiesIndex::MayFly, value);
3526-
}
3527-
if (index == AbilitiesIndex::MayFly && value == false && flying) {
3528-
abilities.setAbility(AbilitiesIndex::Flying, false);
3529-
}
3530-
abilities.setAbility(index, value);
3531-
auto mayfly = abilities.getAbility(AbilitiesIndex::MayFly).getBool();
3532-
auto noclip = abilities.getAbility(AbilitiesIndex::NoClip).getBool();
3533-
player->setCanFly(mayfly || noclip);
3534-
if (index == AbilitiesIndex::NoClip) {
3535-
abilities.setAbility(AbilitiesIndex::Flying, value);
3536-
}
3537-
flying = abilities.getAbility(AbilitiesIndex::Flying).getBool();
3538-
Ability& ab = abilities.getAbility(AbilitiesLayer(1), AbilitiesIndex::Flying);
3539-
ab.setBool(0);
3540-
if (flying) ab.setBool(1);
3541-
UpdateAbilitiesPacket pkt(uid, abilities);
3542-
UpdateAdventureSettingsPacket pkt2 = UpdateAdventureSettingsPacket(AdventureSettings());
3543-
abilities.setAbility(AbilitiesIndex::Flying, flying);
3544-
player->sendNetworkPacket(pkt2);
3545-
player->sendNetworkPacket(pkt);
3519+
player->setAbility(AbilitiesIndex(args[0].asNumber().toInt32()), args[1].asBoolean().value());
35463520
return Boolean::newBoolean(true);
35473521
}
35483522
CATCH("Fail in setAbility!");

0 commit comments

Comments
 (0)