Search in sources :

Example 1 with IColonyRaidEvent

use of com.minecolonies.api.colony.colonyEvents.IColonyRaidEvent in project minecolonies by Minecolonies.

the class RaiderWalkAI method walk.

/**
 * Walk raider towards the colony or campfires
 *
 * @return
 */
private boolean walk() {
    if (raider.getColony() != null) {
        final IColonyEvent event = raider.getColony().getEventManager().getEventByID(raider.getEventID());
        if (event == null) {
            return false;
        }
        if (event.getStatus() == EventStatus.PREPARING && event instanceof HordeRaidEvent) {
            walkToCampFire();
            return false;
        }
        if (targetBlock == null || raider.blockPosition().distSqr(targetBlock) < 25 || raider.level.getGameTime() > walkTimer) {
            targetBlock = raider.getColony().getRaiderManager().getRandomBuilding();
            walkTimer = raider.level.getGameTime() + TICKS_SECOND * 240;
            final BlockPos moveToPos = ShipBasedRaiderUtils.chooseWaypointFor(((IColonyRaidEvent) event).getWayPoints(), raider.blockPosition(), targetBlock);
            raider.getNavigation().moveToXYZ(moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), 1.1);
        } else if (raider.getNavigation().isDone() || raider.getNavigation().getDesiredPos() == null) {
            final BlockPos moveToPos = ShipBasedRaiderUtils.chooseWaypointFor(((IColonyRaidEvent) event).getWayPoints(), raider.blockPosition(), targetBlock);
            raider.getNavigation().moveToXYZ(moveToPos.getX(), moveToPos.getY(), moveToPos.getZ(), 1.1);
        }
    }
    return false;
}
Also used : IColonyEvent(com.minecolonies.api.colony.colonyEvents.IColonyEvent) IColonyRaidEvent(com.minecolonies.api.colony.colonyEvents.IColonyRaidEvent) BlockPos(net.minecraft.util.math.BlockPos) HordeRaidEvent(com.minecolonies.coremod.colony.colonyEvents.raidEvents.HordeRaidEvent)

Aggregations

IColonyEvent (com.minecolonies.api.colony.colonyEvents.IColonyEvent)1 IColonyRaidEvent (com.minecolonies.api.colony.colonyEvents.IColonyRaidEvent)1 HordeRaidEvent (com.minecolonies.coremod.colony.colonyEvents.raidEvents.HordeRaidEvent)1 BlockPos (net.minecraft.util.math.BlockPos)1