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());
}
}
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());
}
}
Aggregations