Search in sources :

Example 1 with BuildingStructureHandler

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

the class AbstractEntityAIStructure method loadStructure.

/**
 * Loads the structure given the name, rotation and position.
 *
 * @param name        the name to retrieve  it.
 * @param rotateTimes number of times to rotateWithMirror it.
 * @param position    the position to set it.
 * @param isMirrored  is the structure mirroed?
 * @param removal     if removal step.
 */
public void loadStructure(@NotNull final String name, final int rotateTimes, final BlockPos position, final boolean isMirrored, final boolean removal) {
    final BuildingStructureHandler<J, B> structure;
    IBuilding colonyBuilding = worker.getCitizenColonyHandler().getColony().getBuildingManager().getBuilding(position);
    final TileEntity entity = world.getBlockEntity(position);
    if (removal) {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { REMOVE_WATER, REMOVE });
        getOwnBuilding().setTotalStages(2);
    } else if ((colonyBuilding != null && (colonyBuilding.getBuildingLevel() > 0 || colonyBuilding.hasParent())) || (entity instanceof TileEntityDecorationController && ((TileEntityDecorationController) entity).getTier() > 0)) {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { BUILD_SOLID, CLEAR_WATER, CLEAR_NON_SOLIDS, DECORATE, SPAWN });
        getOwnBuilding().setTotalStages(5);
    } else {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { CLEAR, BUILD_SOLID, CLEAR_WATER, CLEAR_NON_SOLIDS, DECORATE, SPAWN });
        getOwnBuilding().setTotalStages(6);
    }
    if (!structure.hasBluePrint()) {
        handleSpecificCancelActions();
        Log.getLogger().warn("Couldn't find structure with name: " + name + " aborting loading procedure");
        return;
    }
    job.setBlueprint(structure.getBluePrint());
    job.getBlueprint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(rotateTimes), isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, world);
    setStructurePlacer(structure);
    if (getProgressPos() != null) {
        structure.setStage(getProgressPos().getB());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) TileEntityDecorationController(com.minecolonies.coremod.tileentities.TileEntityDecorationController) Stage(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Example 2 with BuildingStructureHandler

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

the class AbstractEntityAIStructure method loadStructure.

/**
 * Loads the structure given the name, rotation and position.
 *
 * @param name        the name to retrieve  it.
 * @param rotateTimes number of times to rotateWithMirror it.
 * @param position    the position to set it.
 * @param isMirrored  is the structure mirroed?
 * @param removal     if removal step.
 */
public void loadStructure(@NotNull final String name, final int rotateTimes, final BlockPos position, final boolean isMirrored, final boolean removal) {
    final BuildingStructureHandler<J, B> structure;
    IBuilding colonyBuilding = worker.getCitizenColonyHandler().getColony().getBuildingManager().getBuilding(position);
    final TileEntity entity = world.getBlockEntity(position);
    if (removal) {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { REMOVE_WATER, REMOVE });
        getOwnBuilding().setTotalStages(2);
    } else if ((colonyBuilding != null && (colonyBuilding.getBuildingLevel() > 0 || colonyBuilding.hasParent())) || (entity instanceof TileEntityDecorationController && ((TileEntityDecorationController) entity).getTier() > 0)) {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { BUILD_SOLID, CLEAR_WATER, CLEAR_NON_SOLIDS, DECORATE, SPAWN });
        getOwnBuilding().setTotalStages(5);
    } else {
        structure = new BuildingStructureHandler<>(world, position, name, new PlacementSettings(isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, BlockPosUtil.getRotationFromRotations(rotateTimes)), this, new BuildingStructureHandler.Stage[] { CLEAR, BUILD_SOLID, CLEAR_WATER, CLEAR_NON_SOLIDS, DECORATE, SPAWN });
        getOwnBuilding().setTotalStages(6);
    }
    if (!structure.hasBluePrint()) {
        handleSpecificCancelActions();
        Log.getLogger().warn("Couldn't find structure with name: " + name + " aborting loading procedure");
        return;
    }
    job.setBlueprint(structure.getBluePrint());
    job.getBlueprint().rotateWithMirror(BlockPosUtil.getRotationFromRotations(rotateTimes), isMirrored ? Mirror.FRONT_BACK : Mirror.NONE, world);
    setStructurePlacer(structure);
    if (getProgressPos() != null) {
        structure.setStage(getProgressPos().getB());
    }
}
Also used : TileEntity(net.minecraft.tileentity.TileEntity) AxisAlignedBB(net.minecraft.util.math.AxisAlignedBB) BuildingStructureHandler(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler) IBuilding(com.minecolonies.api.colony.buildings.IBuilding) TileEntityDecorationController(com.minecolonies.coremod.tileentities.TileEntityDecorationController) Stage(com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage) PlacementSettings(com.ldtteam.structurize.util.PlacementSettings)

Aggregations

PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 BuildingStructureHandler (com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler)2 Stage (com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage)2 TileEntityDecorationController (com.minecolonies.coremod.tileentities.TileEntityDecorationController)2 TileEntity (net.minecraft.tileentity.TileEntity)2 AxisAlignedBB (net.minecraft.util.math.AxisAlignedBB)2