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;
}
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());
}
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());
}
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;
}
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;
}
Aggregations