Search in sources :

Example 1 with AbstractEntityAIGuard

use of com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard in project minecolonies by ldtteam.

the class AbstractBuildingGuards method startPatrolNext.

/**
 * Starts the patrol to the next point
 */
private void startPatrolNext() {
    getNextPatrolTarget(true);
    patrolTimer = 5;
    for (final ICitizenData curguard : getAllAssignedCitizen()) {
        if (curguard.getEntity().isPresent()) {
            if (curguard.getEntity().get().getCitizenJobHandler().getColonyJob() instanceof AbstractJobGuard) {
                ((AbstractEntityAIGuard<?, ?>) curguard.getEntity().get().getCitizenJobHandler().getColonyJob().getWorkerAI()).setNextPatrolTarget(lastPatrolPoint);
            }
        }
    }
    arrivedAtPatrol.clear();
}
Also used : AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Example 2 with AbstractEntityAIGuard

use of com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard in project minecolonies by ldtteam.

the class EntityCitizen method callForHelp.

@Override
public void callForHelp(final Entity attacker, final int guardHelpRange) {
    if (!(attacker instanceof LivingEntity) || !MineColonies.getConfig().getServer().citizenCallForHelp.get() || callForHelpCooldown != 0) {
        return;
    }
    // Don't call for help when a guard gets woken up
    if (citizenJobHandler.getColonyJob() instanceof AbstractJobGuard && citizenJobHandler.getColonyJob(AbstractJobGuard.class).isAsleep()) {
        return;
    }
    callForHelpCooldown = CALL_HELP_CD;
    List<AbstractEntityCitizen> possibleGuards = new ArrayList<>();
    for (final ICitizenData entry : getCitizenColonyHandler().getColony().getCitizenManager().getCitizens()) {
        if (entry.getEntity().isPresent()) {
            // Checking for guard nearby
            if (entry.getJob() instanceof AbstractJobGuard && entry.getId() != citizenData.getId() && BlockPosUtil.getDistanceSquared(entry.getEntity().get().blockPosition(), blockPosition()) < guardHelpRange && entry.getJob().getWorkerAI() != null) {
                final ThreatTable table = ((EntityCitizen) entry.getEntity().get()).getThreatTable();
                table.addThreat((LivingEntity) attacker, 0);
                if (((AbstractEntityAIGuard<?, ?>) entry.getJob().getWorkerAI()).canHelp()) {
                    possibleGuards.add(entry.getEntity().get());
                }
            }
        }
    }
    Collections.sort(possibleGuards, Comparator.comparingInt(guard -> (int) blockPosition().distSqr(guard.blockPosition())));
    for (int i = 0; i < possibleGuards.size() && i <= CALL_TO_HELP_AMOUNT; i++) {
        ((AbstractEntityAIGuard<?, ?>) possibleGuards.get(i).getCitizenData().getJob().getWorkerAI()).startHelpCitizen((LivingEntity) attacker);
    }
}
Also used : net.minecraft.util(net.minecraft.util) IItemHandler(net.minecraftforge.items.IItemHandler) SittingEntity(com.minecolonies.coremod.entity.SittingEntity) LanguageHandler(com.ldtteam.structurize.util.LanguageHandler) com.minecolonies.coremod.entity.citizen.citizenhandlers(com.minecolonies.coremod.entity.citizen.citizenhandlers) Compatibility(com.minecolonies.api.compatibility.Compatibility) CompoundNBT(net.minecraft.nbt.CompoundNBT) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) com.minecolonies.api.entity.citizen.citizenhandlers(com.minecolonies.api.entity.citizen.citizenhandlers) ThreatTable(com.minecolonies.api.entity.combat.threat.ThreatTable) Status(com.minecolonies.api.entity.ai.Status) CustomGoalSelector(com.minecolonies.api.entity.CustomGoalSelector) ResearchConstants(com.minecolonies.api.research.util.ResearchConstants) ContainerCitizenInventory(com.minecolonies.api.inventory.container.ContainerCitizenInventory) StringTextComponent(net.minecraft.util.text.StringTextComponent) ModItems(com.minecolonies.api.items.ModItems) Network(com.minecolonies.coremod.Network) CitizenConstants(com.minecolonies.api.util.constant.CitizenConstants) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) DesiredActivity(com.minecolonies.api.entity.ai.DesiredActivity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EntityCitizenWalkToProxy(com.minecolonies.coremod.entity.pathfinding.EntityCitizenWalkToProxy) IThreatTableEntity(com.minecolonies.api.entity.combat.threat.IThreatTableEntity) Team(net.minecraft.scoreboard.Team) com.minecolonies.coremod.entity.ai.minimal(com.minecolonies.coremod.entity.ai.minimal) SwimGoal(net.minecraft.entity.ai.goal.SwimGoal) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) ITickRateStateMachine(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.ITickRateStateMachine) Capability(net.minecraftforge.common.capabilities.Capability) EntityAIInteractToggleAble(com.minecolonies.coremod.entity.ai.minimal.EntityAIInteractToggleAble) TeleportHelper(com.minecolonies.coremod.util.TeleportHelper) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EventType(com.minecolonies.api.sounds.EventType) LookAtWithoutMovingGoal(net.minecraft.entity.ai.goal.LookAtWithoutMovingGoal) Vector3d(net.minecraft.util.math.vector.Vector3d) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) MineColonies(com.minecolonies.coremod.MineColonies) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) LocalDate(java.time.LocalDate) IGuardBuilding(com.minecolonies.api.colony.buildings.IGuardBuilding) IState(com.minecolonies.api.entity.ai.statemachine.states.IState) com.minecolonies.coremod.colony.jobs(com.minecolonies.coremod.colony.jobs) ShieldItem(net.minecraft.item.ShieldItem) NotNull(org.jetbrains.annotations.NotNull) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) java.util(java.util) IPermissions(com.minecolonies.api.colony.permissions.IPermissions) OpenInventoryMessage(com.minecolonies.coremod.network.messages.server.colony.OpenInventoryMessage) Container(net.minecraft.inventory.container.Container) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TickingTransition(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickingTransition) NameTagItem(net.minecraft.item.NameTagItem) Action(com.minecolonies.api.colony.permissions.Action) ITextComponent(net.minecraft.util.text.ITextComponent) LazyOptional(net.minecraftforge.common.util.LazyOptional) ItemStack(net.minecraft.item.ItemStack) LookAtGoal(net.minecraft.entity.ai.goal.LookAtGoal) EffectInstance(net.minecraft.potion.EffectInstance) Attributes(net.minecraft.entity.ai.attributes.Attributes) net.minecraft.entity(net.minecraft.entity) com.minecolonies.api.util(com.minecolonies.api.util) INCREMENT_AND_DECREMENT_OPERATORS_SHOULD_NOT_BE_USED_IN_A_METHOD_CALL_OR_MIXED_WITH_OTHER_OPERATORS_IN_AN_EXPRESSION(com.minecolonies.api.util.constant.Suppression.INCREMENT_AND_DECREMENT_OPERATORS_SHOULD_NOT_BE_USED_IN_A_METHOD_CALL_OR_MIXED_WITH_OTHER_OPERATORS_IN_AN_EXPRESSION) com.minecolonies.api.colony(com.minecolonies.api.colony) TickRateStateMachine(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickRateStateMachine) Effects(net.minecraft.potion.Effects) PlayerInventory(net.minecraft.entity.player.PlayerInventory) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) IWalkToProxy(com.minecolonies.api.entity.ai.pathfinding.IWalkToProxy) Month(java.time.Month) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) World(net.minecraft.world.World) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) BlockPos(net.minecraft.util.math.BlockPos) MovementHandler(com.minecolonies.coremod.entity.pathfinding.MovementHandler) PathResult(com.minecolonies.api.entity.pathfinding.PathResult) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) InventoryCitizen(com.minecolonies.api.inventory.InventoryCitizen) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) NbtTagConstants(com.minecolonies.api.util.constant.NbtTagConstants) Clock(java.time.Clock) CitizenDiedEvent(com.minecolonies.coremod.colony.colonyEvents.citizenEvents.CitizenDiedEvent) ItemEntity(net.minecraft.entity.item.ItemEntity) IJob(com.minecolonies.api.colony.jobs.IJob) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) ThreatTable(com.minecolonies.api.entity.combat.threat.ThreatTable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen)

Example 3 with AbstractEntityAIGuard

use of com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard in project minecolonies by Minecolonies.

the class ItemScrollGuardHelp method onItemUseSuccess.

@Override
protected ItemStack onItemUseSuccess(final ItemStack itemStack, final World world, final ServerPlayerEntity player) {
    final IColony colony = getColony(itemStack);
    final BlockPos buildingPos = BlockPosUtil.read(itemStack.getTag(), TAG_BUILDING_POS);
    final IBuilding building = colony.getBuildingManager().getBuilding(buildingPos);
    if (!(building instanceof AbstractBuildingGuards)) {
        MessageUtils.format(TOOL_GUARD_SCROLL_NO_GUARD_BUILDING).sendTo(player);
        return itemStack;
    }
    itemStack.shrink(1);
    final List<ICitizenData> guards = new ArrayList<>(building.getAllAssignedCitizen());
    if (world.random.nextInt(10) == 0 || colony.getWorld() != world) {
        // Fail
        final LlamaEntity entity = EntityType.LLAMA.create(world);
        entity.setPos(player.getX(), player.getY(), player.getZ());
        world.addFreshEntity(entity);
        player.displayClientMessage(new TranslationTextComponent("minecolonies.scroll.failed" + (world.random.nextInt(FAIL_RESPONSES_TOTAL) + 1)).setStyle(Style.EMPTY.withColor(TextFormatting.GOLD)), true);
        SoundUtils.playSoundForPlayer(player, SoundEvents.EVOKER_CAST_SPELL, 0.5f, 1.0f);
        return itemStack;
    } else {
        for (final ICitizenData citizenData : guards) {
            final AbstractJobGuard job = citizenData.getJob(AbstractJobGuard.class);
            if (job != null && job.getWorkerAI() != null && !((AbstractEntityAIGuard) job.getWorkerAI()).hasTool()) {
                continue;
            }
            if (citizenData.getEntity().isPresent()) {
                if (citizenData.getEntity().get().getCitizenDiseaseHandler().isSick()) {
                    continue;
                }
                citizenData.getEntity().get().remove();
            }
            colony.getCitizenManager().spawnOrCreateCivilian(citizenData, world, player.blockPosition(), true);
            citizenData.setNextRespawnPosition(buildingPos);
            ((AbstractBuildingGuards) building).getSetting(AbstractBuildingGuards.GUARD_TASK).set(GuardTaskSetting.FOLLOW);
            ((AbstractBuildingGuards) building).setPlayerToFollow(player);
            final FollowModeSetting grouping = ((AbstractBuildingGuards) building).getSetting(AbstractBuildingGuards.FOLLOW_MODE);
            if (grouping.getValue().equals(FollowModeSetting.LOOSE)) {
                grouping.trigger();
            }
            citizenData.setSaturation(100);
            colony.getPackageManager().addCloseSubscriber(player);
            if (job != null && job.getWorkerAI() != null) {
                final long spawnTime = world.getGameTime() + TICKS_SECOND * 900;
                // Timed despawn
                job.getWorkerAI().registerTarget(new AIOneTimeEventTarget(() -> {
                    if (world.getGameTime() - spawnTime > 0) {
                        ((AbstractBuildingGuards) building).getSetting(AbstractBuildingGuards.GUARD_TASK).set(GuardTaskSetting.PATROL);
                        citizenData.getEntity().ifPresent(Entity::remove);
                        colony.getPackageManager().removeCloseSubscriber(player);
                        return true;
                    }
                    return false;
                }, AIWorkerState.DECIDE));
            }
        }
        SoundUtils.playSoundForPlayer(player, SoundEvents.UI_TOAST_CHALLENGE_COMPLETE, 0.3f, 1.0f);
    }
    return itemStack;
}
Also used : AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ArrayList(java.util.ArrayList) AIOneTimeEventTarget(com.minecolonies.api.entity.ai.statemachine.AIOneTimeEventTarget) IColony(com.minecolonies.api.colony.IColony) ICitizenData(com.minecolonies.api.colony.ICitizenData) AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) LlamaEntity(net.minecraft.entity.passive.horse.LlamaEntity) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) BlockPos(net.minecraft.util.math.BlockPos) FollowModeSetting(com.minecolonies.coremod.colony.buildings.modules.settings.FollowModeSetting)

Example 4 with AbstractEntityAIGuard

use of com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard in project minecolonies by Minecolonies.

the class EntityCitizen method callForHelp.

@Override
public void callForHelp(final Entity attacker, final int guardHelpRange) {
    if (!(attacker instanceof LivingEntity) || !MineColonies.getConfig().getServer().citizenCallForHelp.get() || callForHelpCooldown != 0) {
        return;
    }
    // Don't call for help when a guard gets woken up
    if (citizenJobHandler.getColonyJob() instanceof AbstractJobGuard && citizenJobHandler.getColonyJob(AbstractJobGuard.class).isAsleep()) {
        return;
    }
    callForHelpCooldown = CALL_HELP_CD;
    List<AbstractEntityCitizen> possibleGuards = new ArrayList<>();
    for (final ICitizenData entry : getCitizenColonyHandler().getColony().getCitizenManager().getCitizens()) {
        if (entry.getEntity().isPresent()) {
            // Checking for guard nearby
            if (entry.getJob() instanceof AbstractJobGuard && entry.getId() != citizenData.getId() && BlockPosUtil.getDistanceSquared(entry.getEntity().get().blockPosition(), blockPosition()) < guardHelpRange && entry.getJob().getWorkerAI() != null) {
                final ThreatTable table = ((EntityCitizen) entry.getEntity().get()).getThreatTable();
                table.addThreat((LivingEntity) attacker, 0);
                if (((AbstractEntityAIGuard<?, ?>) entry.getJob().getWorkerAI()).canHelp()) {
                    possibleGuards.add(entry.getEntity().get());
                }
            }
        }
    }
    Collections.sort(possibleGuards, Comparator.comparingInt(guard -> (int) blockPosition().distSqr(guard.blockPosition())));
    for (int i = 0; i < possibleGuards.size() && i <= CALL_TO_HELP_AMOUNT; i++) {
        ((AbstractEntityAIGuard<?, ?>) possibleGuards.get(i).getCitizenData().getJob().getWorkerAI()).startHelpCitizen((LivingEntity) attacker);
    }
}
Also used : net.minecraft.util(net.minecraft.util) IItemHandler(net.minecraftforge.items.IItemHandler) SittingEntity(com.minecolonies.coremod.entity.SittingEntity) com.minecolonies.coremod.entity.citizen.citizenhandlers(com.minecolonies.coremod.entity.citizen.citizenhandlers) Compatibility(com.minecolonies.api.compatibility.Compatibility) CompoundNBT(net.minecraft.nbt.CompoundNBT) StandardFactoryController(com.minecolonies.api.colony.requestsystem.StandardFactoryController) com.minecolonies.api.entity.citizen.citizenhandlers(com.minecolonies.api.entity.citizen.citizenhandlers) ThreatTable(com.minecolonies.api.entity.combat.threat.ThreatTable) Status(com.minecolonies.api.entity.ai.Status) CustomGoalSelector(com.minecolonies.api.entity.CustomGoalSelector) ResearchConstants(com.minecolonies.api.research.util.ResearchConstants) ContainerCitizenInventory(com.minecolonies.api.inventory.container.ContainerCitizenInventory) ModItems(com.minecolonies.api.items.ModItems) Network(com.minecolonies.coremod.Network) CitizenConstants(com.minecolonies.api.util.constant.CitizenConstants) Constants(com.minecolonies.api.util.constant.Constants) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) DesiredActivity(com.minecolonies.api.entity.ai.DesiredActivity) PlayerEntity(net.minecraft.entity.player.PlayerEntity) EntityCitizenWalkToProxy(com.minecolonies.coremod.entity.pathfinding.EntityCitizenWalkToProxy) Skill(com.minecolonies.api.entity.citizen.Skill) IThreatTableEntity(com.minecolonies.api.entity.combat.threat.IThreatTableEntity) Team(net.minecraft.scoreboard.Team) com.minecolonies.coremod.entity.ai.minimal(com.minecolonies.coremod.entity.ai.minimal) SwimGoal(net.minecraft.entity.ai.goal.SwimGoal) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) ITickRateStateMachine(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.ITickRateStateMachine) Capability(net.minecraftforge.common.capabilities.Capability) EntityAIInteractToggleAble(com.minecolonies.coremod.entity.ai.minimal.EntityAIInteractToggleAble) TeleportHelper(com.minecolonies.coremod.util.TeleportHelper) Nullable(org.jetbrains.annotations.Nullable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) EventType(com.minecolonies.api.sounds.EventType) LookAtWithoutMovingGoal(net.minecraft.entity.ai.goal.LookAtWithoutMovingGoal) Vector3d(net.minecraft.util.math.vector.Vector3d) WorkerBuildingModule(com.minecolonies.coremod.colony.buildings.modules.WorkerBuildingModule) MineColonies(com.minecolonies.coremod.MineColonies) CapabilityItemHandler(net.minecraftforge.items.CapabilityItemHandler) LocalDate(java.time.LocalDate) IGuardBuilding(com.minecolonies.api.colony.buildings.IGuardBuilding) IState(com.minecolonies.api.entity.ai.statemachine.states.IState) com.minecolonies.coremod.colony.jobs(com.minecolonies.coremod.colony.jobs) ShieldItem(net.minecraft.item.ShieldItem) NotNull(org.jetbrains.annotations.NotNull) ServerPlayerEntity(net.minecraft.entity.player.ServerPlayerEntity) net.minecraft.util.text(net.minecraft.util.text) java.util(java.util) IPermissions(com.minecolonies.api.colony.permissions.IPermissions) OpenInventoryMessage(com.minecolonies.coremod.network.messages.server.colony.OpenInventoryMessage) Container(net.minecraft.inventory.container.Container) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) TickingTransition(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickingTransition) NameTagItem(net.minecraft.item.NameTagItem) ItemParticleEffectMessage(com.minecolonies.coremod.network.messages.client.ItemParticleEffectMessage) ISFOOD(com.minecolonies.api.util.ItemStackUtils.ISFOOD) Action(com.minecolonies.api.colony.permissions.Action) LazyOptional(net.minecraftforge.common.util.LazyOptional) AbstractEntityAIBasic(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIBasic) ItemStack(net.minecraft.item.ItemStack) LookAtGoal(net.minecraft.entity.ai.goal.LookAtGoal) EffectInstance(net.minecraft.potion.EffectInstance) Attributes(net.minecraft.entity.ai.attributes.Attributes) net.minecraft.entity(net.minecraft.entity) com.minecolonies.api.util(com.minecolonies.api.util) INCREMENT_AND_DECREMENT_OPERATORS_SHOULD_NOT_BE_USED_IN_A_METHOD_CALL_OR_MIXED_WITH_OTHER_OPERATORS_IN_AN_EXPRESSION(com.minecolonies.api.util.constant.Suppression.INCREMENT_AND_DECREMENT_OPERATORS_SHOULD_NOT_BE_USED_IN_A_METHOD_CALL_OR_MIXED_WITH_OTHER_OPERATORS_IN_AN_EXPRESSION) com.minecolonies.api.colony(com.minecolonies.api.colony) TickRateStateMachine(com.minecolonies.api.entity.ai.statemachine.tickratestatemachine.TickRateStateMachine) Effects(net.minecraft.potion.Effects) PlayerInventory(net.minecraft.entity.player.PlayerInventory) AbstractBuildingGuards(com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) IWalkToProxy(com.minecolonies.api.entity.ai.pathfinding.IWalkToProxy) Month(java.time.Month) ILocation(com.minecolonies.api.colony.requestsystem.location.ILocation) World(net.minecraft.world.World) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) BlockPos(net.minecraft.util.math.BlockPos) Items(net.minecraft.item.Items) VanillaParticleMessage(com.minecolonies.coremod.network.messages.client.VanillaParticleMessage) MovementHandler(com.minecolonies.coremod.entity.pathfinding.MovementHandler) ParticleTypes(net.minecraft.particles.ParticleTypes) PathResult(com.minecolonies.api.entity.pathfinding.PathResult) TypeConstants(com.minecolonies.api.util.constant.TypeConstants) InventoryCitizen(com.minecolonies.api.inventory.InventoryCitizen) EquipmentSlotType(net.minecraft.inventory.EquipmentSlotType) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) NbtTagConstants(com.minecolonies.api.util.constant.NbtTagConstants) Clock(java.time.Clock) CitizenDiedEvent(com.minecolonies.coremod.colony.colonyEvents.citizenEvents.CitizenDiedEvent) ItemEntity(net.minecraft.entity.item.ItemEntity) IJob(com.minecolonies.api.colony.jobs.IJob) MonsterEntity(net.minecraft.entity.monster.MonsterEntity) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen) ThreatTable(com.minecolonies.api.entity.combat.threat.ThreatTable) AbstractEntityCitizen(com.minecolonies.api.entity.citizen.AbstractEntityCitizen)

Example 5 with AbstractEntityAIGuard

use of com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard in project minecolonies by Minecolonies.

the class AbstractBuildingGuards method startPatrolNext.

/**
 * Starts the patrol to the next point
 */
private void startPatrolNext() {
    getNextPatrolTarget(true);
    patrolTimer = 5;
    for (final ICitizenData curguard : getAllAssignedCitizen()) {
        if (curguard.getEntity().isPresent()) {
            if (curguard.getEntity().get().getCitizenJobHandler().getColonyJob() instanceof AbstractJobGuard) {
                ((AbstractEntityAIGuard<?, ?>) curguard.getEntity().get().getCitizenJobHandler().getColonyJob().getWorkerAI()).setNextPatrolTarget(lastPatrolPoint);
            }
        }
    }
    arrivedAtPatrol.clear();
}
Also used : AbstractJobGuard(com.minecolonies.coremod.colony.jobs.AbstractJobGuard) AbstractEntityAIGuard(com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard) ICitizenData(com.minecolonies.api.colony.ICitizenData)

Aggregations

AbstractEntityAIGuard (com.minecolonies.coremod.entity.ai.citizen.guard.AbstractEntityAIGuard)6 ICitizenData (com.minecolonies.api.colony.ICitizenData)4 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)4 AbstractBuildingGuards (com.minecolonies.coremod.colony.buildings.AbstractBuildingGuards)4 AbstractJobGuard (com.minecolonies.coremod.colony.jobs.AbstractJobGuard)4 BlockPos (net.minecraft.util.math.BlockPos)4 com.minecolonies.api.colony (com.minecolonies.api.colony)2 IColony (com.minecolonies.api.colony.IColony)2 IGuardBuilding (com.minecolonies.api.colony.buildings.IGuardBuilding)2 ChatPriority (com.minecolonies.api.colony.interactionhandling.ChatPriority)2 IJob (com.minecolonies.api.colony.jobs.IJob)2 Action (com.minecolonies.api.colony.permissions.Action)2 IPermissions (com.minecolonies.api.colony.permissions.IPermissions)2 StandardFactoryController (com.minecolonies.api.colony.requestsystem.StandardFactoryController)2 ILocation (com.minecolonies.api.colony.requestsystem.location.ILocation)2 Compatibility (com.minecolonies.api.compatibility.Compatibility)2 CustomGoalSelector (com.minecolonies.api.entity.CustomGoalSelector)2 DesiredActivity (com.minecolonies.api.entity.ai.DesiredActivity)2 Status (com.minecolonies.api.entity.ai.Status)2 IWalkToProxy (com.minecolonies.api.entity.ai.pathfinding.IWalkToProxy)2