Search in sources :

Example 6 with VisitorData

use of com.minecolonies.coremod.colony.VisitorData in project minecolonies by ldtteam.

the class EntityAIVisitor method decide.

/**
 * Decides on the next activity
 *
 * @return next state
 */
private VisitorState decide() {
    if (shouldFight()) {
        return VisitorState.COMBAT;
    }
    final int random = citizen.getRandom().nextInt(5);
    if (tavern != null && (random == 0 || random == 1 && !citizen.getCitizenColonyHandler().getColony().isDay()) && tavern.hasModule(TavernBuildingModule.class)) {
        final BlockPos pos = tavern.getFirstModuleOccurance(TavernBuildingModule.class).getFreeSitPosition();
        if (pos != null) {
            ((VisitorData) citizen.getCitizenData()).setSittingPosition(pos);
            citizen.isWorkerAtSiteWithMove(pos, 1);
            actionTimeoutCounter = citizen.getRandom().nextInt(2500) + 3000;
            return VisitorState.SITTING;
        }
    } else if (random == 2) {
        citizen.getNavigation().moveToRandomPos(10, 0.6D);
        actionTimeoutCounter = citizen.getCitizenColonyHandler().getColony().isDay() ? citizen.getRandom().nextInt(1000) + 1000 : 300;
        return VisitorState.WANDERING;
    }
    return VisitorState.IDLE;
}
Also used : VisitorData(com.minecolonies.coremod.colony.VisitorData) BlockPos(net.minecraft.util.math.BlockPos) TavernBuildingModule(com.minecolonies.coremod.colony.buildings.modules.TavernBuildingModule)

Aggregations

VisitorData (com.minecolonies.coremod.colony.VisitorData)6 IVisitorData (com.minecolonies.api.colony.IVisitorData)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 TavernBuildingModule (com.minecolonies.coremod.colony.buildings.modules.TavernBuildingModule)2 BlockPos (net.minecraft.util.math.BlockPos)2