use of com.minecolonies.api.colony.buildings.IBuilding in project minecolonies by Minecolonies.
the class EntityAIQuarrier method loadRequirements.
@Override
public IAIState loadRequirements() {
if (job.getWorkOrder() == null) {
final IBuilding quarry = job.findQuarry();
if (quarry == null || quarry.getFirstModuleOccurance(QuarryModule.class).isFinished()) {
return IDLE;
}
final String name = Structures.SCHEMATICS_PREFIX + "/" + quarry.getStyle() + "/" + quarry.getSchematicName() + "shaft1";
final WorkOrderMiner wo = new WorkOrderMiner(name, name, quarry.getRotation(), quarry.getPosition().below(2), false, building.getPosition());
building.getColony().getWorkManager().addWorkOrder(wo, false);
job.setWorkOrder(wo);
}
return super.loadRequirements();
}
use of com.minecolonies.api.colony.buildings.IBuilding in project minecolonies by Minecolonies.
the class CombatUtils method notifyGuardsOfTarget.
/**
* Actions on changing to a new target entity
*/
public static void notifyGuardsOfTarget(final AbstractEntityCitizen user, final LivingEntity target, final int callRange) {
for (final ICitizenData citizen : user.getCitizenData().getWorkBuilding().getAllAssignedCitizen()) {
if (citizen.getEntity().isPresent() && citizen.getEntity().get().getLastHurtByMob() == null) {
((EntityCitizen) citizen.getEntity().get()).getThreatTable().addThreat(target, 0);
}
}
if (target instanceof AbstractEntityMinecoloniesMob) {
for (final Map.Entry<BlockPos, IBuilding> entry : user.getCitizenColonyHandler().getColony().getBuildingManager().getBuildings().entrySet()) {
if (entry.getValue() instanceof AbstractBuildingGuards && user.blockPosition().distSqr(entry.getKey()) < callRange) {
final AbstractBuildingGuards building = (AbstractBuildingGuards) entry.getValue();
building.setTempNextPatrolPoint(target.blockPosition());
}
}
}
}
use of com.minecolonies.api.colony.buildings.IBuilding in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method checkForWorkOrder.
/**
* Checks if we got a valid workorder.
*
* @return true if we got a workorder to work with
*/
private boolean checkForWorkOrder() {
if (!job.hasWorkOrder()) {
building.searchWorkOrder();
building.setProgressPos(null, BuildingStructureHandler.Stage.CLEAR);
return false;
}
final IWorkOrder wo = job.getWorkOrder();
if (wo == null) {
job.setWorkOrder(null);
building.setProgressPos(null, null);
return false;
}
final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getLocation());
if (building == null && wo instanceof WorkOrderBuilding && wo.getWorkOrderType() != WorkOrderType.REMOVE) {
job.complete();
return false;
}
return true;
}
use of com.minecolonies.api.colony.buildings.IBuilding in project minecolonies by Minecolonies.
the class EntityAIStructureBuilder method killMobs.
/**
* Kill all mobs at the building site.
*/
private void killMobs() {
if (building.getBuildingLevel() >= LEVEL_TO_PURGE_MOBS && job.getWorkOrder().getWorkOrderType() == WorkOrderType.BUILD) {
final BlockPos buildingPos = job.getWorkOrder().getLocation();
final IBuilding building = worker.getCitizenColonyHandler().getColony().getBuildingManager().getBuilding(buildingPos);
if (building != null) {
WorldUtil.getEntitiesWithinBuilding(world, MonsterEntity.class, building, null).forEach(Entity::remove);
}
}
}
use of com.minecolonies.api.colony.buildings.IBuilding in project minecolonies by Minecolonies.
the class EntityAIWorkDeliveryman method pickup.
/**
* Pickup items from a hut that has requested a pickup.
*
* @return the next state to go to.
*/
private IAIState pickup() {
final IRequest<? extends IDeliverymanRequestable> currentTask = job.getCurrentTask();
if (!(currentTask instanceof PickupRequest)) {
// The current task has changed since the Decision-state. Restart.
return START_WORKING;
}
if (cannotHoldMoreItems()) {
this.alreadyKept = new ArrayList<>();
this.currentSlot = 0;
return DUMPING;
}
worker.getCitizenData().setVisibleStatus(DELIVERING);
worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.gathering"));
final BlockPos pickupTarget = currentTask.getRequester().getLocation().getInDimensionLocation();
if (pickupTarget != BlockPos.ZERO && !worker.isWorkerAtSiteWithMove(pickupTarget, MIN_DISTANCE_TO_WAREHOUSE)) {
setDelay(WALK_DELAY);
return PICKUP;
}
final IBuilding pickupBuilding = building.getColony().getBuildingManager().getBuilding(pickupTarget);
if (pickupBuilding == null) {
job.finishRequest(false);
return START_WORKING;
}
if (pickupFromBuilding(pickupBuilding)) {
this.alreadyKept = new ArrayList<>();
this.currentSlot = 0;
job.finishRequest(true);
if (currentTask.getRequest().getPriority() >= PRIORITY_FORCING_DUMP) {
return DUMPING;
} else {
return START_WORKING;
}
} else if (InventoryUtils.openSlotCount(worker.getInventoryCitizen()) <= 0) {
this.alreadyKept = new ArrayList<>();
this.currentSlot = 0;
return DUMPING;
}
currentSlot++;
return PICKUP;
}
Aggregations