use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class EntityAIWorkDeliveryman method checkIfExecute.
/**
* Check if the deliveryman code should be executed.
* More concretely if he has a warehouse to work at.
*
* @return false if should continue as planned.
*/
private boolean checkIfExecute() {
worker.setAIMoveSpeed((float) (BASE_MOVEMENT_SPEED + BASE_MOVEMENT_SPEED * worker.getLevel() / WALKING_SPEED_MULTIPLIER));
if (getWareHouse() != null && getWareHouse().getTileEntity() != null) {
return false;
}
final Map<BlockPos, AbstractBuilding> buildings = job.getColony().getBuildingManager().getBuildings();
for (final AbstractBuilding building : buildings.values()) {
if (building == null) {
continue;
}
final Colony buildingColony = building.getColony();
final Colony ownColony = worker.getColony();
if (building instanceof BuildingWareHouse && ownColony != null && buildingColony != null && buildingColony.getID() == ownColony.getID() && ((BuildingWareHouse) building).registerWithWareHouse((BuildingDeliveryman) this.getOwnBuilding())) {
return false;
}
}
chatSpamFilter.talkWithoutSpam(COM_MINECOLONIES_COREMOD_JOB_DELIVERYMAN_NOWAREHOUSE);
return true;
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class EntityAIWorkDeliveryman method gather.
/**
* Gather items from a random hut which the hut doesn't need.
*
* @return the next state to go to.
*/
public AIState gather() {
if (maximalGatherCount < 0) {
maximalGatherCount = Configurations.requestSystem.minimalBuildingsToGather + worker.getRandom().nextInt(Math.max(1, Configurations.requestSystem.maximalBuildingsToGather - Configurations.requestSystem.minimalBuildingsToGather));
}
if (gatherTarget == null) {
if (gatherCount == maximalGatherCount) {
maximalGatherCount = Configurations.requestSystem.minimalBuildingsToGather + worker.getRandom().nextInt(Math.max(1, Configurations.requestSystem.maximalBuildingsToGather - Configurations.requestSystem.minimalBuildingsToGather));
gatherCount = 0;
return DUMPING;
}
gatherTarget = getRandomBuilding();
}
if (gatherTarget == null) {
return START_WORKING;
}
worker.setLatestStatus(new TextComponentTranslation("com.minecolonies.coremod.status.gathering"));
if (!worker.isWorkerAtSiteWithMove(gatherTarget, MIN_DISTANCE_TO_WAREHOUSE)) {
return GATHERING;
}
final Colony colony = getOwnBuilding().getColony();
if (colony != null) {
final AbstractBuilding building = colony.getBuildingManager().getBuilding(gatherTarget);
if (building == null) {
gatherTarget = null;
return START_WORKING;
}
if (gatherFromBuilding(building) || cannotHoldMoreItems()) {
this.alreadyKept = new ArrayList<>();
this.currentSlot = 0;
building.setBeingGathered(false);
gatherCount++;
if (hasGathered) {
this.hasGathered = false;
building.alterPickUpPriority(1);
} else {
building.alterPickUpPriority(-1);
if (job.getCurrentTask() == null) {
gatherTarget = null;
return GATHERING;
}
}
gatherCount = 0;
return DUMPING;
}
currentSlot++;
return GATHERING;
}
return START_WORKING;
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class AbstractEntityAIGuard method onKilledEntity.
/**
* Called when a guard killed an entity.
*
* @param killedEntity the entity being killed.
*/
protected void onKilledEntity(final EntityLivingBase killedEntity) {
final Colony colony = this.getOwnBuilding().getColony();
colony.getStatsManager().incrementStatistic("mobs");
this.incrementActionsDoneAndDecSaturation();
worker.getNavigator().clearPath();
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class ShowColonyInfoCommand method execute.
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
// See if we have a valid colony,
Colony colony = actionMenu.getColonyForArgument("colony");
EntityPlayer player = null;
if (null == colony) {
// see if we have a valid player
player = actionMenu.getPlayerForArgument("player");
if (null != player) {
final IColony iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), player);
if (iColony != null) {
if (!canPlayerUseCommand(player, SHOWCOLONYINFO, iColony.getID())) {
sender.sendMessage(new TextComponentString(NOT_PERMITTED));
return;
}
colony = ColonyManager.getColony(iColony.getID());
}
}
}
if (null == colony) {
// see if we have a sender that is a valid player
if (sender instanceof EntityPlayer) {
player = (EntityPlayer) sender;
final UUID mayorID = player.getUniqueID();
final IColony iColony = ColonyManager.getIColonyByOwner(sender.getEntityWorld(), mayorID);
if (iColony != null) {
if (!canPlayerUseCommand(player, SHOWCOLONYINFO, iColony.getID())) {
sender.sendMessage(new TextComponentString(NOT_PERMITTED));
return;
}
colony = ColonyManager.getColony(iColony.getID());
}
}
}
if (colony == null) {
if (null != player) {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOR_PLAYER_FOUND_MESSAGE, player.getName())));
} else {
sender.sendMessage(new TextComponentString(String.format(NO_COLONY_FOUND_MESSAGE)));
}
return;
}
executeShared(server, sender, colony);
}
use of com.minecolonies.coremod.colony.Colony in project minecolonies by Minecolonies.
the class RSResetCommand method execute.
@Override
public void execute(@NotNull final MinecraftServer server, @NotNull final ICommandSender sender, @NotNull final ActionMenu actionMenu) throws CommandException {
final Colony colony = actionMenu.getColonyForArgument("colony");
if (colony == null) {
sender.sendMessage(new TextComponentString(COLONY_NOT_FOUND));
return;
}
executeShared(server, sender, colony);
}
Aggregations