use of com.minecolonies.coremod.colony.StructureName in project minecolonies by Minecolonies.
the class BuildingUtils method getTargetAbleArea.
/**
* Calculate the Size of the building given a world and a building.
* @param world the world.
* @param building the building.
* @return the AxisAlignedBB box.
*/
public static AxisAlignedBB getTargetAbleArea(final World world, final AbstractBuilding building) {
final BlockPos location = building.getLocation();
final int x1;
final int z1;
final int x3;
final int z3;
final int y1 = location.getY() - 2;
final int y3;
if (building.getHeight() == 0) {
final StructureName sn = new StructureName(Structures.SCHEMATICS_PREFIX, building.getStyle(), building.getSchematicName() + building.getBuildingLevel());
final String structureName = sn.toString();
final StructureWrapper wrapper = new StructureWrapper(world, structureName);
wrapper.rotate(building.getRotation(), world, location, building.isMirrored() ? Mirror.FRONT_BACK : Mirror.NONE);
final BlockPos pos = location;
wrapper.setPosition(pos);
x1 = wrapper.getPosition().getX() - wrapper.getOffset().getX() - 1;
z1 = wrapper.getPosition().getZ() - wrapper.getOffset().getZ() - 1;
x3 = wrapper.getPosition().getX() + (wrapper.getWidth() - wrapper.getOffset().getX());
z3 = wrapper.getPosition().getZ() + (wrapper.getLength() - wrapper.getOffset().getZ());
y3 = location.getY() + wrapper.getHeight();
building.setCorners(x1, x3, z1, z3);
building.setHeight(wrapper.getHeight());
} else {
final Tuple<Tuple<Integer, Integer>, Tuple<Integer, Integer>> corners = building.getCorners();
x1 = corners.getFirst().getFirst();
x3 = corners.getFirst().getSecond();
z1 = corners.getSecond().getFirst();
z3 = corners.getSecond().getSecond();
y3 = location.getY() + building.getHeight();
}
return new AxisAlignedBB(x1, y1, z1, x3, y3, z3);
}
Aggregations