Search in sources :

Example 1 with WorkerLoadOnlyStructureHandler

use of com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler in project minecolonies by Minecolonies.

the class EntityAIQuarrier method requestMaterials.

@Override
public boolean requestMaterials() {
    StructurePhasePlacementResult result;
    final WorkerLoadOnlyStructureHandler structure = new WorkerLoadOnlyStructureHandler(world, structurePlacer.getB().getWorldPos(), structurePlacer.getB().getBluePrint(), new PlacementSettings(), true, this);
    job.getWorkOrder().setIteratorType("default");
    final StructurePlacer placer = new StructurePlacer(structure, job.getWorkOrder().getIteratorType());
    if (requestProgress == null) {
        final AbstractBuildingStructureBuilder buildingWorker = getOwnBuilding();
        buildingWorker.resetNeededResources();
        requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), structurePlacer.getB().getBluePrint().getSizeY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
        requestState = RequestStage.SOLID;
    }
    final BlockPos worldPos = structure.getProgressPosInWorld(requestProgress);
    final RequestStage currState = requestState;
    switch(currState) {
        case SOLID:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().decrement(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> !info.getBlockInfo().getState().getMaterial().isSolid() || isDecoItem(info.getBlockInfo().getState().getBlock()) || pos.getY() < worldPos.getY())), false);
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (requestProgress.getY() != -1 && result.getIteratorPos().getY() < requestProgress.getY()) {
                requestProgress = new BlockPos(0, requestProgress.getY() + 1, 0);
                requestState = RequestStage.DECO;
            } else if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestProgress = new BlockPos(0, structurePlacer.getB().getBluePrint().getSizeY() - 2, 0);
                requestState = RequestStage.DECO;
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
        case DECO:
            if (requestProgress.getY() >= structurePlacer.getB().getBluePrint().getSizeY()) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
                return false;
            }
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getBlockInfo().getState().getMaterial().isSolid() && !isDecoItem(info.getBlockInfo().getState().getBlock()) || pos.getY() > worldPos.getY())), false);
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else if (requestProgress.getY() != -1 && result.getIteratorPos().getY() > requestProgress.getY()) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
        case ENTITIES:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().decrement(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getEntities().length == 0 || pos.getY() < worldPos.getY())), true);
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.SOLID;
                requestProgress = null;
                return true;
            } else if (requestProgress.getY() != -1 && (result.getIteratorPos().getY() < requestProgress.getY())) {
                requestState = RequestStage.SOLID;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
    }
    return true;
}
Also used : AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) FluidState(net.minecraft.fluid.FluidState) BLOCK_PLACE_SPEED(com.minecolonies.api.research.util.ResearchConstants.BLOCK_PLACE_SPEED) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) Structures(com.ldtteam.structurize.management.Structures) IBuilderUndestroyable(com.minecolonies.api.entity.ai.citizen.builder.IBuilderUndestroyable) BuildingBuilder(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBuilder) Direction(net.minecraft.util.Direction) TileEntityDecorationController(com.minecolonies.coremod.tileentities.TileEntityDecorationController) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) RECALC(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure.ItemCheckResult.RECALC) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) ISettingsModule(com.minecolonies.api.colony.buildings.modules.ISettingsModule) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) Constants(com.minecolonies.api.util.constant.Constants) MORE_ORES(com.minecolonies.api.research.util.ResearchConstants.MORE_ORES) Fluids(net.minecraft.fluid.Fluids) JobQuarrier(com.minecolonies.coremod.colony.jobs.JobQuarrier) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AbstractEntityAIStructureWithWorkOrder(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructureWithWorkOrder) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) FILL_BLOCK(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner.FILL_BLOCK) MineColonies(com.minecolonies.coremod.MineColonies) NotNull(org.jetbrains.annotations.NotNull) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) SurfaceType(com.minecolonies.api.entity.pathfinding.SurfaceType) Mirror(net.minecraft.util.Mirror) ItemStack(net.minecraft.item.ItemStack) StructureIterators(com.ldtteam.structurize.placement.StructureIterators) net.minecraft.block(net.minecraft.block) AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) Hand(net.minecraft.util.Hand) com.minecolonies.api.util(com.minecolonies.api.util) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) IColonyManager(com.minecolonies.api.colony.IColonyManager) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) WorkOrderBuildMiner(com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner) Items(net.minecraft.item.Items) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) PROGRESS_MULTIPLIER(com.minecolonies.api.util.constant.CitizenConstants.PROGRESS_MULTIPLIER) Stage(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) QuarryModule(com.minecolonies.coremod.colony.buildings.modules.QuarryModule) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) ItemStack(net.minecraft.item.ItemStack)

Example 2 with WorkerLoadOnlyStructureHandler

use of com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler in project minecolonies by ldtteam.

the class AbstractEntityAIStructureWithWorkOrder method requestMaterials.

@Override
public boolean requestMaterials() {
    StructurePhasePlacementResult result;
    final WorkerLoadOnlyStructureHandler structure = new WorkerLoadOnlyStructureHandler(world, structurePlacer.getB().getWorldPos(), structurePlacer.getB().getBluePrint(), new PlacementSettings(), true, this);
    if (job.getWorkOrder().getIteratorType().isEmpty() && getOwnBuilding().hasModule(ISettingsModule.class) && getOwnBuilding().getSetting(BuildingBuilder.BUILDING_MODE) != null) {
        job.getWorkOrder().setIteratorType(getOwnBuilding().getSetting(BuildingBuilder.BUILDING_MODE).getValue());
    }
    final StructurePlacer placer = new StructurePlacer(structure, job.getWorkOrder().getIteratorType());
    if (requestProgress == null) {
        final AbstractBuildingStructureBuilder buildingWorker = getOwnBuilding();
        buildingWorker.resetNeededResources();
        requestProgress = NULL_POS;
        requestState = RequestStage.SOLID;
    }
    final RequestStage currState = requestState;
    switch(currState) {
        case SOLID:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> !info.getBlockInfo().getState().getMaterial().isSolid() || isDecoItem(info.getBlockInfo().getState().getBlock()))), false);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.DECO;
            }
            return false;
        case DECO:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getBlockInfo().getState().getMaterial().isSolid() && !isDecoItem(info.getBlockInfo().getState().getBlock()))), false);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.ENTITIES;
            }
            return false;
        case ENTITIES:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getEntities().length == 0)), true);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.SOLID;
                requestProgress = null;
                return true;
            }
            return false;
        default:
            return true;
    }
}
Also used : AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) PICK_UP_RESIDUALS(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState.PICK_UP_RESIDUALS) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) BuildingBuilder(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBuilder) COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE) ItemStack(net.minecraft.item.ItemStack) Tuple(com.minecolonies.api.util.Tuple) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) ISettingsModule(com.minecolonies.api.colony.buildings.modules.ISettingsModule) Log(com.minecolonies.api.util.Log) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) Constants(com.minecolonies.api.util.constant.Constants) BuildingBuiltEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingBuiltEvent) BuildingDeconstructedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingDeconstructedEvent) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) STACKSIZE(com.minecolonies.api.util.constant.Constants.STACKSIZE) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) IDLE(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState.IDLE) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) BuildingUpgradedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent) Nullable(org.jetbrains.annotations.Nullable) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDSTART(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDSTART) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) com.minecolonies.coremod.colony.workorders(com.minecolonies.coremod.colony.workorders) AbstractJobStructure(com.minecolonies.coremod.colony.jobs.AbstractJobStructure) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) NotNull(org.jetbrains.annotations.NotNull) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) ItemStack(net.minecraft.item.ItemStack)

Example 3 with WorkerLoadOnlyStructureHandler

use of com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler in project minecolonies by ldtteam.

the class EntityAIQuarrier method requestMaterials.

@Override
public boolean requestMaterials() {
    StructurePhasePlacementResult result;
    final WorkerLoadOnlyStructureHandler structure = new WorkerLoadOnlyStructureHandler(world, structurePlacer.getB().getWorldPos(), structurePlacer.getB().getBluePrint(), new PlacementSettings(), true, this);
    job.getWorkOrder().setIteratorType("default");
    final StructurePlacer placer = new StructurePlacer(structure, job.getWorkOrder().getIteratorType());
    if (requestProgress == null) {
        final AbstractBuildingStructureBuilder buildingWorker = getOwnBuilding();
        buildingWorker.resetNeededResources();
        requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), structurePlacer.getB().getBluePrint().getSizeY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
        requestState = RequestStage.SOLID;
    }
    final BlockPos worldPos = structure.getProgressPosInWorld(requestProgress);
    final RequestStage currState = requestState;
    switch(currState) {
        case SOLID:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().decrement(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> !info.getBlockInfo().getState().getMaterial().isSolid() || isDecoItem(info.getBlockInfo().getState().getBlock()) || pos.getY() < worldPos.getY())), false);
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (requestProgress.getY() != -1 && result.getIteratorPos().getY() < requestProgress.getY()) {
                requestProgress = new BlockPos(0, requestProgress.getY() + 1, 0);
                requestState = RequestStage.DECO;
            } else if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestProgress = new BlockPos(0, structurePlacer.getB().getBluePrint().getSizeY() - 2, 0);
                requestState = RequestStage.DECO;
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
        case DECO:
            if (requestProgress.getY() >= structurePlacer.getB().getBluePrint().getSizeY()) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
                return false;
            }
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getBlockInfo().getState().getMaterial().isSolid() && !isDecoItem(info.getBlockInfo().getState().getBlock()) || pos.getY() > worldPos.getY())), false);
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else if (requestProgress.getY() != -1 && result.getIteratorPos().getY() > requestProgress.getY()) {
                requestState = RequestStage.ENTITIES;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
        case ENTITIES:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().decrement(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getEntities().length == 0 || pos.getY() < worldPos.getY())), true);
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.SOLID;
                requestProgress = null;
                return true;
            } else if (requestProgress.getY() != -1 && (result.getIteratorPos().getY() < requestProgress.getY())) {
                requestState = RequestStage.SOLID;
                requestProgress = new BlockPos(structurePlacer.getB().getBluePrint().getSizeX(), requestProgress.getY() - 1, structurePlacer.getB().getBluePrint().getSizeZ() - 1);
            } else {
                requestProgress = result.getIteratorPos();
            }
            return false;
    }
    return true;
}
Also used : AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) FluidState(net.minecraft.fluid.FluidState) BLOCK_PLACE_SPEED(com.minecolonies.api.research.util.ResearchConstants.BLOCK_PLACE_SPEED) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) Structures(com.ldtteam.structurize.management.Structures) IBuilderUndestroyable(com.minecolonies.api.entity.ai.citizen.builder.IBuilderUndestroyable) BuildingBuilder(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBuilder) Direction(net.minecraft.util.Direction) TileEntityDecorationController(com.minecolonies.coremod.tileentities.TileEntityDecorationController) TranslationTextComponent(net.minecraft.util.text.TranslationTextComponent) RECALC(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructure.ItemCheckResult.RECALC) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) ISettingsModule(com.minecolonies.api.colony.buildings.modules.ISettingsModule) AITarget(com.minecolonies.api.entity.ai.statemachine.AITarget) TICKS_SECOND(com.minecolonies.api.util.constant.Constants.TICKS_SECOND) Constants(com.minecolonies.api.util.constant.Constants) MORE_ORES(com.minecolonies.api.research.util.ResearchConstants.MORE_ORES) Fluids(net.minecraft.fluid.Fluids) JobQuarrier(com.minecolonies.coremod.colony.jobs.JobQuarrier) TranslationConstants(com.minecolonies.api.util.constant.TranslationConstants) AbstractEntityAIStructureWithWorkOrder(com.minecolonies.coremod.entity.ai.basic.AbstractEntityAIStructureWithWorkOrder) ChatPriority(com.minecolonies.api.colony.interactionhandling.ChatPriority) StandardInteraction(com.minecolonies.coremod.colony.interactionhandling.StandardInteraction) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) FILL_BLOCK(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner.FILL_BLOCK) MineColonies(com.minecolonies.coremod.MineColonies) NotNull(org.jetbrains.annotations.NotNull) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) SurfaceType(com.minecolonies.api.entity.pathfinding.SurfaceType) Mirror(net.minecraft.util.Mirror) ItemStack(net.minecraft.item.ItemStack) StructureIterators(com.ldtteam.structurize.placement.StructureIterators) net.minecraft.block(net.minecraft.block) AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) Hand(net.minecraft.util.Hand) com.minecolonies.api.util(com.minecolonies.api.util) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) BuildingMiner(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingMiner) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) IColonyManager(com.minecolonies.api.colony.IColonyManager) VisibleCitizenStatus(com.minecolonies.api.entity.citizen.VisibleCitizenStatus) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) WorkOrderBuildMiner(com.minecolonies.coremod.colony.workorders.WorkOrderBuildMiner) Items(net.minecraft.item.Items) AIWorkerState(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState) PROGRESS_MULTIPLIER(com.minecolonies.api.util.constant.CitizenConstants.PROGRESS_MULTIPLIER) Stage(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) ResourceLocation(net.minecraft.util.ResourceLocation) TileEntity(net.minecraft.tileentity.TileEntity) QuarryModule(com.minecolonies.coremod.colony.buildings.modules.QuarryModule) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) BlockPos(net.minecraft.util.math.BlockPos) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) ItemStack(net.minecraft.item.ItemStack)

Example 4 with WorkerLoadOnlyStructureHandler

use of com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler in project minecolonies by Minecolonies.

the class AbstractEntityAIStructureWithWorkOrder method requestMaterials.

@Override
public boolean requestMaterials() {
    StructurePhasePlacementResult result;
    final WorkerLoadOnlyStructureHandler structure = new WorkerLoadOnlyStructureHandler(world, structurePlacer.getB().getWorldPos(), structurePlacer.getB().getBluePrint(), new PlacementSettings(), true, this);
    if (job.getWorkOrder().getIteratorType().isEmpty() && getOwnBuilding().hasModule(ISettingsModule.class) && getOwnBuilding().getSetting(BuildingBuilder.BUILDING_MODE) != null) {
        job.getWorkOrder().setIteratorType(getOwnBuilding().getSetting(BuildingBuilder.BUILDING_MODE).getValue());
    }
    final StructurePlacer placer = new StructurePlacer(structure, job.getWorkOrder().getIteratorType());
    if (requestProgress == null) {
        final AbstractBuildingStructureBuilder buildingWorker = getOwnBuilding();
        buildingWorker.resetNeededResources();
        requestProgress = NULL_POS;
        requestState = RequestStage.SOLID;
    }
    final RequestStage currState = requestState;
    switch(currState) {
        case SOLID:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> !info.getBlockInfo().getState().getMaterial().isSolid() || isDecoItem(info.getBlockInfo().getState().getBlock()))), false);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.DECO;
            }
            return false;
        case DECO:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getBlockInfo().getState().getMaterial().isSolid() && !isDecoItem(info.getBlockInfo().getState().getBlock()))), false);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.ENTITIES;
            }
            return false;
        case ENTITIES:
            result = placer.executeStructureStep(world, null, requestProgress, StructurePlacer.Operation.GET_RES_REQUIREMENTS, () -> placer.getIterator().increment(DONT_TOUCH_PREDICATE.or((info, pos, handler) -> info.getEntities().length == 0)), true);
            requestProgress = result.getIteratorPos();
            for (final ItemStack stack : result.getBlockResult().getRequiredItems()) {
                getOwnBuilding().addNeededResource(stack, stack.getCount());
            }
            if (result.getBlockResult().getResult() == BlockPlacementResult.Result.FINISHED) {
                requestState = RequestStage.SOLID;
                requestProgress = null;
                return true;
            }
            return false;
        default:
            return true;
    }
}
Also used : AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) PICK_UP_RESIDUALS(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState.PICK_UP_RESIDUALS) ItemStackUtils(com.minecolonies.api.util.ItemStackUtils) AbstractTileEntityColonyBuilding(com.minecolonies.api.tileentities.AbstractTileEntityColonyBuilding) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) BuildingBuilder(com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBuilder) COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_DECONSTRUCTION_COMPLETE) ItemStack(net.minecraft.item.ItemStack) Tuple(com.minecolonies.api.util.Tuple) BuildingBuilderResource(com.minecolonies.coremod.colony.buildings.utils.BuildingBuilderResource) IAIState(com.minecolonies.api.entity.ai.statemachine.states.IAIState) AbstractBuildingStructureBuilder(com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder) ISettingsModule(com.minecolonies.api.colony.buildings.modules.ISettingsModule) Log(com.minecolonies.api.util.Log) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) IBlueprintDataProvider(com.ldtteam.structurize.blocks.interfaces.IBlueprintDataProvider) Constants(com.minecolonies.api.util.constant.Constants) BuildingBuiltEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingBuiltEvent) BuildingDeconstructedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingDeconstructedEvent) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) STACKSIZE(com.minecolonies.api.util.constant.Constants.STACKSIZE) BlockPos(net.minecraft.util.math.BlockPos) NULL_POS(com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS) IDLE(com.minecolonies.api.entity.ai.statemachine.states.AIWorkerState.IDLE) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) BuildingUpgradedEvent(com.minecolonies.coremod.colony.colonyEvents.buildingEvents.BuildingUpgradedEvent) Nullable(org.jetbrains.annotations.Nullable) BlockPlacementResult(com.ldtteam.structurize.placement.BlockPlacementResult) COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDSTART(com.minecolonies.api.util.constant.TranslationConstants.COM_MINECOLONIES_COREMOD_ENTITY_BUILDER_BUILDSTART) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) com.minecolonies.coremod.colony.workorders(com.minecolonies.coremod.colony.workorders) AbstractJobStructure(com.minecolonies.coremod.colony.jobs.AbstractJobStructure) TileEntity(net.minecraft.tileentity.TileEntity) ItemStorage(com.minecolonies.api.crafting.ItemStorage) WorldUtil(com.minecolonies.api.util.WorldUtil) NotNull(org.jetbrains.annotations.NotNull) StructurePhasePlacementResult(com.ldtteam.structurize.placement.StructurePhasePlacementResult) StructurePlacer(com.ldtteam.structurize.placement.StructurePlacer) WorkerLoadOnlyStructureHandler(com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings) ItemStack(net.minecraft.item.ItemStack)

Aggregations

NULL_POS (com.ldtteam.structurize.placement.AbstractBlueprintIterator.NULL_POS)4 BlockPlacementResult (com.ldtteam.structurize.placement.BlockPlacementResult)4 StructurePhasePlacementResult (com.ldtteam.structurize.placement.StructurePhasePlacementResult)4 StructurePlacer (com.ldtteam.structurize.placement.StructurePlacer)4 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)4 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)4 ISettingsModule (com.minecolonies.api.colony.buildings.modules.ISettingsModule)4 IAIState (com.minecolonies.api.entity.ai.statemachine.states.IAIState)4 Constants (com.minecolonies.api.util.constant.Constants)4 AbstractBuildingStructureBuilder (com.minecolonies.coremod.colony.buildings.AbstractBuildingStructureBuilder)4 BuildingBuilder (com.minecolonies.coremod.colony.buildings.workerbuildings.BuildingBuilder)4 BuildingStructureHandler (com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler)4 WorkerLoadOnlyStructureHandler (com.minecolonies.coremod.entity.ai.util.WorkerLoadOnlyStructureHandler)4 ItemStack (net.minecraft.item.ItemStack)4 TileEntity (net.minecraft.tileentity.TileEntity)4 BlockPos (net.minecraft.util.math.BlockPos)4 NotNull (org.jetbrains.annotations.NotNull)4 Structures (com.ldtteam.structurize.management.Structures)2 StructureIterators (com.ldtteam.structurize.placement.StructureIterators)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2