Search in sources :

Example 6 with TileEntityDecorationController

use of com.minecolonies.coremod.tileentities.TileEntityDecorationController 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

TileEntityDecorationController (com.minecolonies.coremod.tileentities.TileEntityDecorationController)6 TileEntity (net.minecraft.tileentity.TileEntity)6 PlacementSettings (com.ldtteam.structurize.util.PlacementSettings)4 BlockState (net.minecraft.block.BlockState)4 PlayerEntity (net.minecraft.entity.player.PlayerEntity)4 Blueprint (com.ldtteam.structures.blueprints.v1.Blueprint)2 IColony (com.minecolonies.api.colony.IColony)2 IColonyManager (com.minecolonies.api.colony.IColonyManager)2 IBuilding (com.minecolonies.api.colony.buildings.IBuilding)2 Action (com.minecolonies.api.colony.permissions.Action)2 IWorkOrder (com.minecolonies.api.colony.workorders.IWorkOrder)2 IMessage (com.minecolonies.api.network.IMessage)2 LoadOnlyStructureHandler (com.minecolonies.api.util.LoadOnlyStructureHandler)2 Log (com.minecolonies.api.util.Log)2 BlockDecorationController (com.minecolonies.coremod.blocks.BlockDecorationController)2 WorkOrderBuildDecoration (com.minecolonies.coremod.colony.workorders.WorkOrderBuildDecoration)2 BuildingStructureHandler (com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler)2 Stage (com.minecolonies.coremod.entity.ai.util.BuildingStructureHandler.Stage)2 Map (java.util.Map)2 Optional (java.util.Optional)2