Search in sources :

Example 1 with VisitorData

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

the class VisitorManager method createAndRegisterCivilianData.

@Override
public IVisitorData createAndRegisterCivilianData() {
    markDirty();
    final IVisitorData data = new VisitorData(nextVisitorID--, colony);
    data.initForNewCivilian();
    visitorMap.put(data.getId(), data);
    return data;
}
Also used : IVisitorData(com.minecolonies.api.colony.IVisitorData) VisitorData(com.minecolonies.coremod.colony.VisitorData) IVisitorData(com.minecolonies.api.colony.IVisitorData)

Example 2 with VisitorData

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

the class EntityAIVisitor method isEntityLoaded.

/**
 * Whether the entity is in a ticked chunk
 *
 * @return true if loaded
 */
private boolean isEntityLoaded() {
    if (citizen.getCitizenColonyHandler().getColony() == null || citizen.getCitizenData() == null || citizen.getCitizenData().getHomeBuilding() == null) {
        return false;
    }
    IBuilding building = citizen.getCitizenData().getHomeBuilding();
    if (building.hasModule(TavernBuildingModule.class)) {
        tavern = (DefaultBuildingInstance) building;
    }
    ((VisitorData) citizen.getCitizenData()).setSittingPosition(BlockPos.ZERO);
    return WorldUtil.isEntityBlockLoaded(citizen.level, citizen.blockPosition());
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) VisitorData(com.minecolonies.coremod.colony.VisitorData)

Example 3 with VisitorData

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

the class EntityAIVisitor method isEntityLoaded.

/**
 * Whether the entity is in a ticked chunk
 *
 * @return true if loaded
 */
private boolean isEntityLoaded() {
    if (citizen.getCitizenColonyHandler().getColony() == null || citizen.getCitizenData() == null || citizen.getCitizenData().getHomeBuilding() == null) {
        return false;
    }
    IBuilding building = citizen.getCitizenData().getHomeBuilding();
    if (building.hasModule(TavernBuildingModule.class)) {
        tavern = (DefaultBuildingInstance) building;
    }
    ((VisitorData) citizen.getCitizenData()).setSittingPosition(BlockPos.ZERO);
    return WorldUtil.isEntityBlockLoaded(citizen.level, citizen.blockPosition());
}
Also used : IBuilding(com.minecolonies.api.colony.buildings.IBuilding) VisitorData(com.minecolonies.coremod.colony.VisitorData)

Example 4 with VisitorData

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

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)

Example 5 with VisitorData

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

the class VisitorManager method createAndRegisterCivilianData.

@Override
public IVisitorData createAndRegisterCivilianData() {
    markDirty();
    final IVisitorData data = new VisitorData(nextVisitorID--, colony);
    data.initForNewCivilian();
    visitorMap.put(data.getId(), data);
    return data;
}
Also used : IVisitorData(com.minecolonies.api.colony.IVisitorData) VisitorData(com.minecolonies.coremod.colony.VisitorData) IVisitorData(com.minecolonies.api.colony.IVisitorData)

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