Skip to content

Warning Task

Praneet Dhoolia edited this page Oct 17, 2023 · 9 revisions

Description

The WarningTask is ran for 3 seconds to allow the WarningComponent to display an incoming mob warning.

Functionality

The starting time is stored in a long startTime variable. With every update, the task updates the owner's WarningComponent, checks for the 3 second limit, and exits along with the component using the following methodology:

public void update() {
    owner.getEntity().getComponent(WarningComponent.class).update();
    if (ServiceLocator.getTimeSource().getTime() > startTime + 3000) {
        owner.getEntity().dispose();
    }
}
Clone this wiki locally