Search in sources :

Example 1 with GraveyardManagementModule

use of com.minecolonies.coremod.colony.buildings.modules.GraveyardManagementModule in project minecolonies by Minecolonies.

the class EntityAIWorkUndertaker method buryCitizen.

/**
 * The Undertaker search for an empty grave site in the graveyard and build a named graved with
 * the name of the citizen and its job as text
 *
 * @return the next IAIState
 */
private IAIState buryCitizen() {
    @Nullable final BuildingGraveyard buildingGraveyard = building;
    final GraveyardManagementModule module = buildingGraveyard.getFirstModuleOccurance(GraveyardManagementModule.class);
    if (checkForToolOrWeapon(ToolType.SHOVEL) || module.getLastGraveData() == null) {
        return IDLE;
    }
    worker.getCitizenData().setVisibleStatus(BURYING_ICON);
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent(MESSAGE_INFO_CITIZEN_UNDERTAKER_BURYING));
    if (burialPos == null || !world.getBlockState(burialPos.getA()).isAir()) {
        burialPos = building.getRandomFreeVisualGravePos();
    }
    if (burialPos == null || burialPos.getA() == null) {
        // couldn't find a place to dig a grave
        worker.getCitizenChatHandler().sendLocalizedChat(new TranslationTextComponent(MESSAGE_INFO_CITIZEN_UNDERTAKER_GRAVEYARD_NO_SPACE, module.getLastGraveData().getCitizenName()));
        return IDLE;
    }
    if (walkToBlock(burialPos.getA(), 3)) {
        return getState();
    }
    if (effortCounter < EFFORT_BURY) {
        equipShovel();
        worker.swing(Hand.MAIN_HAND);
        effortCounter += getPrimarySkillLevel();
        return getState();
    }
    effortCounter = 0;
    unequip();
    module.buryCitizenHere(burialPos);
    // Disabled until Mourning AI update: worker.getCitizenColonyHandler().getColony().setNeedToMourn(false, buildingGraveyard.getLastGraveData().getCitizenName());
    AdvancementUtils.TriggerAdvancementPlayersForColony(worker.getCitizenColonyHandler().getColony(), playerMP -> AdvancementTriggers.CITIZEN_BURY.trigger(playerMP));
    module.setLastGraveData(null);
    burialPos = null;
    shouldDumpInventory = true;
    return INVENTORY_FULL;
}
Also used : BuildingGraveyard(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingGraveyard) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Nullable(org.jetbrains.annotations.Nullable) GraveyardManagementModule(com.minecolonies.coremod.colony.buildings.modules.GraveyardManagementModule)

Example 2 with GraveyardManagementModule

use of com.minecolonies.coremod.colony.buildings.modules.GraveyardManagementModule in project minecolonies by ldtteam.

the class EntityAIWorkUndertaker method buryCitizen.

/**
 * The Undertaker search for an empty grave site in the graveyard and build a named graved with
 * the name of the citizen and its job as text
 *
 * @return the next IAIState
 */
private IAIState buryCitizen() {
    @Nullable final BuildingGraveyard buildingGraveyard = getOwnBuilding();
    final GraveyardManagementModule module = buildingGraveyard.getFirstModuleOccurance(GraveyardManagementModule.class);
    if (checkForToolOrWeapon(ToolType.SHOVEL) || module.getLastGraveData() == null) {
        return IDLE;
    }
    worker.getCitizenData().setVisibleStatus(BURYING_ICON);
    worker.getCitizenStatusHandler().setLatestStatus(new TranslationTextComponent("com.minecolonies.coremod.status.burying"));
    if (burialPos == null || !world.getBlockState(burialPos.getA()).isAir()) {
        burialPos = getOwnBuilding().getRandomFreeVisualGravePos();
    }
    if (burialPos == null || burialPos.getA() == null) {
        // coudn't find a place to dig a grave
        LanguageHandler.sendPlayersMessage(buildingGraveyard.getColony().getImportantMessageEntityPlayers(), "com.minecolonies.coremod.nospaceforgrave", module.getLastGraveData().getCitizenName());
        return IDLE;
    }
    if (walkToBlock(burialPos.getA(), 3)) {
        return getState();
    }
    if (effortCounter < EFFORT_BURY) {
        equipShovel();
        worker.swing(Hand.MAIN_HAND);
        effortCounter += getPrimarySkillLevel();
        return getState();
    }
    effortCounter = 0;
    unequip();
    module.buryCitizenHere(burialPos);
    // Disabled until Mourning AI update: worker.getCitizenColonyHandler().getColony().setNeedToMourn(false, buildingGraveyard.getLastGraveData().getCitizenName());
    AdvancementUtils.TriggerAdvancementPlayersForColony(worker.getCitizenColonyHandler().getColony(), playerMP -> AdvancementTriggers.CITIZEN_BURY.trigger(playerMP));
    module.setLastGraveData(null);
    burialPos = null;
    shouldDumpInventory = true;
    return INVENTORY_FULL;
}
Also used : BuildingGraveyard(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingGraveyard) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) Nullable(org.jetbrains.annotations.Nullable) GraveyardManagementModule(com.minecolonies.coremod.colony.buildings.modules.GraveyardManagementModule)

Aggregations

GraveyardManagementModule (com.minecolonies.coremod.colony.buildings.modules.GraveyardManagementModule)2 BuildingGraveyard (com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingGraveyard)2 TranslationTextComponent (net.minecraft.util.text.TranslationTextComponent)2 Nullable (org.jetbrains.annotations.Nullable)2