Search in sources :

Example 1 with CraftStatus

use of net.countercraft.movecraft.craft.CraftStatus in project Movecraft by APDevTeam.

the class AsyncManager method detectSinking.

private void detectSinking() {
    for (Craft craft : CraftManager.getInstance()) {
        if (craft instanceof SinkingCraft)
            continue;
        if (craft.getType().getDoubleProperty(CraftType.SINK_PERCENT) == 0.0 || !craft.isNotProcessing())
            continue;
        long ticksElapsed = (System.currentTimeMillis() - craft.getLastBlockCheck()) / 50;
        if (ticksElapsed <= Settings.SinkCheckTicks)
            continue;
        CraftStatus status = checkCraftStatus(craft);
        // Only do this if the craft isn't already disabled.
        if (status.isDisabled() && craft.isNotProcessing() && !craft.getDisabled()) {
            craft.setDisabled(true);
            craft.getAudience().playSound(Sound.sound(Key.key("entity.iron_golem.death"), Sound.Source.NEUTRAL, 5.0f, 5.0f));
        }
        // update the time for the next check
        if (status.isSinking() && craft.isNotProcessing()) {
            craft.getAudience().sendMessage(I18nSupport.getInternationalisedComponent("Player - Craft is sinking"));
            craft.setCruising(false);
            CraftManager.getInstance().sink(craft);
        } else {
            craft.setLastBlockCheck(System.currentTimeMillis());
        }
    }
}
Also used : SinkingCraft(net.countercraft.movecraft.craft.SinkingCraft) SinkingCraft(net.countercraft.movecraft.craft.SinkingCraft) PilotedCraft(net.countercraft.movecraft.craft.PilotedCraft) PlayerCraft(net.countercraft.movecraft.craft.PlayerCraft) Craft(net.countercraft.movecraft.craft.Craft) CraftStatus(net.countercraft.movecraft.craft.CraftStatus)

Aggregations

Craft (net.countercraft.movecraft.craft.Craft)1 CraftStatus (net.countercraft.movecraft.craft.CraftStatus)1 PilotedCraft (net.countercraft.movecraft.craft.PilotedCraft)1 PlayerCraft (net.countercraft.movecraft.craft.PlayerCraft)1 SinkingCraft (net.countercraft.movecraft.craft.SinkingCraft)1