Files
MinecraftConsoles/Minecraft.World/OpenDoorGoal.cpp
2026-03-01 12:16:08 +08:00

35 lines
685 B
C++

#include "stdafx.h"
#include "net.minecraft.world.entity.h"
#include "net.minecraft.world.level.tile.h"
#include "OpenDoorGoal.h"
OpenDoorGoal::OpenDoorGoal(Mob *mob, bool closeDoorAfter) : DoorInteractGoal(mob)
{
this->mob = mob;
this->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();
}