4jcraft/Minecraft.World/AI/Goals/OpenDoorGoal.cpp
2026-03-21 15:10:07 -05:00

30 lines
758 B
C++

#include "../../Platform/stdafx.h"
#include "../../Headers/net.minecraft.world.entity.h"
#include "../../Headers/net.minecraft.world.level.tile.h"
#include "OpenDoorGoal.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();
}