4jcraft/targets/minecraft/world/entity/ai/goal/OpenDoorGoal.cpp
2026-04-01 18:17:44 -05:00

31 lines
762 B
C++

#include "OpenDoorGoal.h"
#include "minecraft/world/entity/Mob.h"
#include "minecraft/world/entity/ai/goal/DoorInteractGoal.h"
#include "minecraft/world/level/tile/DoorTile.h"
OpenDoorGoal::OpenDoorGoal(Mob* mob, bool closeDoorAfter)
: DoorInteractGoal(mob) {
this->mob = mob;
closeDoor = closeDoorAfter;
}
bool OpenDoorGoal::canContinueToUse() {
return closeDoor && forgetTime > 0 && DoorInteractGoal::canContinueToUse();
}
void OpenDoorGoal::start() {
forgetTime = 20;
doorTile->setOpen(mob->level, doorX, doorY, doorZ, true);
}
void OpenDoorGoal::stop() {
if (closeDoor) {
doorTile->setOpen(mob->level, doorX, doorY, doorZ, false);
}
}
void OpenDoorGoal::tick() {
--forgetTime;
DoorInteractGoal::tick();
}