Search in sources :

Example 1 with BuildingUpgradedEvent

use of com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent in project minecolonies by Minecolonies.

the class AbstractEntityAIStructureWithWorkOrder method executeSpecificCompleteActions.

@Override
public void executeSpecificCompleteActions() {
    if (job.getBlueprint() == null && job.hasWorkOrder()) {
        // fix for bad structures
        job.complete();
    }
    if (job.getBlueprint() == null) {
        return;
    }
    final String structureName = job.getBlueprint().getName();
    final WorkOrderBuildDecoration wo = job.getWorkOrder();
    if (wo instanceof WorkOrderBuildBuilding) {
        sendCompletionMessage(wo);
        WorkOrderBuild wob = (WorkOrderBuild) wo;
        String buildingName = wo.getStructureName();
        buildingName = buildingName.substring(buildingName.indexOf('/') + 1, buildingName.lastIndexOf('/')) + " " + buildingName.substring(buildingName.lastIndexOf('/') + 1, buildingName.lastIndexOf(String.valueOf(wob.getUpgradeLevel())));
        job.getColony().getEventDescriptionManager().addEventDescription(wob.getUpgradeLevel() > 1 ? new BuildingUpgradedEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()) : new BuildingBuiltEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()));
    } else if (wo instanceof WorkOrderBuildRemoval) {
        worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE, structureName);
        WorkOrderBuild wob = (WorkOrderBuild) wo;
        String buildingName = wo.getStructureName();
        buildingName = buildingName.substring(buildingName.indexOf('/') + 1, buildingName.lastIndexOf('/')) + " " + buildingName.substring(buildingName.lastIndexOf('/') + 1, buildingName.indexOf(String.valueOf(wob.getUpgradeLevel())));
        job.getColony().getEventDescriptionManager().addEventDescription(new BuildingDeconstructedEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()));
    } else {
        sendCompletionMessage(wo);
    }
    if (wo == null) {
        Log.getLogger().error(String.format("Worker (%d:%d) ERROR - Finished, but missing work order(%d)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), job.getWorkOrderId()));
    } else {
        job.complete();
        if (wo instanceof WorkOrderBuildBuilding) {
            final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getSchematicLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getSchematicLocation()));
            } else {
                // Normally levels are done through the schematic data, but incase it is missing we do it manually here.
                final TileEntity te = worker.level.getBlockEntity(building.getID());
                if (te instanceof AbstractTileEntityColonyBuilding && ((IBlueprintDataProvider) te).getSchematicName().isEmpty()) {
                    building.onUpgradeComplete(((WorkOrderBuildBuilding) wo).getUpgradeLevel());
                    building.setBuildingLevel(((WorkOrderBuildBuilding) wo).getUpgradeLevel());
                }
            }
        } else if (wo instanceof WorkOrderBuildRemoval) {
            final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getSchematicLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getSchematicLocation()));
            } else {
                building.setDeconstructed();
            }
        }
    }
    getOwnBuilding().resetNeededResources();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BuildingDeconstructedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingDeconstructedEvent) BuildingBuiltEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingBuiltEvent) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) BuildingUpgradedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent)

Example 2 with BuildingUpgradedEvent

use of com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent in project minecolonies by ldtteam.

the class AbstractEntityAIStructureWithWorkOrder method executeSpecificCompleteActions.

@Override
public void executeSpecificCompleteActions() {
    if (job.getBlueprint() == null && job.hasWorkOrder()) {
        // fix for bad structures
        job.complete();
    }
    if (job.getBlueprint() == null) {
        return;
    }
    final String structureName = job.getBlueprint().getName();
    final WorkOrderBuildDecoration wo = job.getWorkOrder();
    if (wo instanceof WorkOrderBuildBuilding) {
        sendCompletionMessage(wo);
        WorkOrderBuild wob = (WorkOrderBuild) wo;
        String buildingName = wo.getStructureName();
        buildingName = buildingName.substring(buildingName.indexOf('/') + 1, buildingName.lastIndexOf('/')) + " " + buildingName.substring(buildingName.lastIndexOf('/') + 1, buildingName.lastIndexOf(String.valueOf(wob.getUpgradeLevel())));
        job.getColony().getEventDescriptionManager().addEventDescription(wob.getUpgradeLevel() > 1 ? new BuildingUpgradedEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()) : new BuildingBuiltEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()));
    } else if (wo instanceof WorkOrderBuildRemoval) {
        worker.getCitizenChatHandler().sendLocalizedChat(COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE, structureName);
        WorkOrderBuild wob = (WorkOrderBuild) wo;
        String buildingName = wo.getStructureName();
        buildingName = buildingName.substring(buildingName.indexOf('/') + 1, buildingName.lastIndexOf('/')) + " " + buildingName.substring(buildingName.lastIndexOf('/') + 1, buildingName.indexOf(String.valueOf(wob.getUpgradeLevel())));
        job.getColony().getEventDescriptionManager().addEventDescription(new BuildingDeconstructedEvent(wo.getSchematicLocation(), buildingName, wob.getUpgradeLevel()));
    } else {
        sendCompletionMessage(wo);
    }
    if (wo == null) {
        Log.getLogger().error(String.format("Worker (%d:%d) ERROR - Finished, but missing work order(%d)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), job.getWorkOrderId()));
    } else {
        job.complete();
        if (wo instanceof WorkOrderBuildBuilding) {
            final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getSchematicLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getSchematicLocation()));
            } else {
                // Normally levels are done through the schematic data, but incase it is missing we do it manually here.
                final TileEntity te = worker.level.getBlockEntity(building.getID());
                if (te instanceof AbstractTileEntityColonyBuilding && ((IBlueprintDataProvider) te).getSchematicName().isEmpty()) {
                    building.onUpgradeComplete(((WorkOrderBuildBuilding) wo).getUpgradeLevel());
                    building.setBuildingLevel(((WorkOrderBuildBuilding) wo).getUpgradeLevel());
                }
            }
        } else if (wo instanceof WorkOrderBuildRemoval) {
            final IBuilding building = job.getColony().getBuildingManager().getBuilding(wo.getSchematicLocation());
            if (building == null) {
                Log.getLogger().error(String.format("Builder (%d:%d) ERROR - Finished, but missing building(%s)", worker.getCitizenColonyHandler().getColony().getID(), worker.getCitizenData().getId(), wo.getSchematicLocation()));
            } else {
                building.setDeconstructed();
            }
        }
    }
    getOwnBuilding().resetNeededResources();
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) BuildingDeconstructedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingDeconstructedEvent) BuildingBuiltEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingBuiltEvent) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) BuildingUpgradedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent)

Aggregations

IBlueprintDataProvider (com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 AbstractTileEntityColonyBuilding (com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding)2 BuildingBuiltEvent (com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingBuiltEvent)2 BuildingDeconstructedEvent (com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingDeconstructedEvent)2 BuildingUpgradedEvent (com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent)2 TileEntity (net.minecraft.tileentity.TileEntity)2